I'm writing WCF service. I need to pass XML to service and then to write that XML to database which is not important right now. Something like this:
[OperationContract]
void InsertReport(XmlObjectSerializer xmlDoc);
Anyone did this?
[EDIT]
I also need to test this, but WCF default client cant do that...
You can easily solve this by generating a sting from the xml. The saved data in the database will always get converted to a string anway.
Related
I've been having trouble accomplishing the following task and was looking for input from the community on how I might go about solving it; if this is the wrong place to post this, please let me know and I will move it.
Using a SSIS package I am trying to:
Read values from an XML document.
Pass those values to a web service.
Record the return value in a new XML document (or a flat-file for simplicity sake).
For reference, let's take a simple example. I want to pass a series of currency types to this web service:
http://www.webservicex.net/ConvertTemperature.asmx
So far I have:
Added HTTP Connection Manager - Configured to access the WSDL file at http://www.webservicex.net/CurrencyConvertor.asmx?wsdl
Created a Web Service Task using the HTTP Connection, made and referenced the WSDL file.
The input fields can be selected manually, for example, CAD to USD.
The output can be easily saved to a specified output.
I have two main problems; the first would be passing the columns from the XML source to the web service and the second is I'm not sure how to handle the datatypes of the web service. In the example web service, the datatype for the currency is "Currency" but that is not a defined datatype within BIDS.
Any advice on this matter would be greatly appreciated.
emphasized textcheck out this link which passes data from a flat file source to a web service.
http://www.vsteamsystemcentral.com/cs/blogs/applied_team_system/archive/2007/01/10/247.aspx
I am going to have XML output from web service. in fact, I write a method in web service that returns a first of objects, now I want to have this list of objects in XML format in client side.
Does web service produce XML output?
If yes, how can I get XML in client side?
I don't want to write XML document in web service
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
return
<string>Hello World</string>
Please help me
I'm not entirely sure your question makes sense:
does web service produce XML output?
It can pretty much return whatever you like. You can make it return raw xml, you can make it return XmlNode-objects, or something similar.
This is what confuses me:
I don't want to write XML document in web service
Does this mean you don't want to build the XML-object at all, on the server side? If so, it will be up to your client to create the xml. How you can do that obviously depends on what data you are returning. I don't think there is any "magic" in c# that will do this for you automatically, just because it is a response from a WS.
Regarding your specific issue, you can find some guidance here.
When defining the details of your data contract and your WCF endpoint, you can decide the exact communication protocol and the form used to return your results. There, you could set the options of using REST or SOAP (see this for more) or returning results as JSON or raw data.
Hope I helped!
I'm retrieving some userdata from a phpbb3 forum through scripts on the server.
My database does not allow for external login, so I have to go through some kind of script.
But, I'd like to know if there is a safe enough way to retrieve this data?
I know how to output some XML with echo statements, but I'm not sure if this is as secure as it should be?
Optimal method would be (psuedo code)
$array['user_id'] = $id;
$array['otherinfo'] = $var
return $array;
if I could somehow read this array with C#, it would be much easier, but I'm not sure how this would work with WebResonses or whatnot.
Any ideas?
You need a web service, that will output your responses in some format that you can parse with C#.
Php and C# are not interoperable, that s why you will need to create a service that you can consume these messages.
First option as I said is to create a web service, that C# code can consume. In this case, your C# code should know what to ask from your php web service, and you will respond to the request, in XML, or JSON or whatever format you want to use within your C# code to parse it.
Another option is to push the data to a web service that uses C#. You need to write a WCF/ Web service, and you can push the data to this service.
I suggest you to give your array output as xml or json. If we take xml as consideration, you can call the php file which gives xml output like this:
XDocument.Load("http://whatever.com/whatever.php");
And ofc you need to add the System.Xml.Linq header to use XDocument class. And also you can pass a hashed key, etc. from query string to validate the requested is coming from your app.
I'm trying to to generate web service proxy class using ServiceContractGenerator.
But the problem is that i want to recieve a "raw" xml from webservice (it may be a string or XmlNode, doesnt matter).
Is there any way to modify web service contracts before generating proxy or do something else to get what i need?
If you are talking about Wsdl then it should either been exposed from the webservice. or rather provided to you via .wsdl file.
I've got wcf service for wcf straming. I works.
But I must integrate it with our webserice.
is there any way, to have webmethod like this:
[webmethod]
public Stream GetStream(string path)
{
return Iservice.GetStream(path);
}
I service is a class which I copy from WCF service to my asmx.
And is there any way to integrate App.config from wcf with web.config ?
Sorry, no, ASMX web services don't support streaming.
What is the bigger picture here, what are you trying to archieve with this stream?
Like John Saunders already said: Webservices dont support it. This is behaviour by design: Data is serialized into a platform/language independent and human readable xml packet, sent and deserialized on the receiver side. Of course you could go and split up your stream into chunks and send it piece for piece. But it wouldnt really make sense to misuse webservices like that, plus you are adding huge overhead in bandwidth and processing time.