Reputation: 1438
i'm using web services in my application.
So, I add a service references with the url of the web service.
Then, I create an object implemtation client, that can call method of the webservice.
The methods take a lot of arguments.
When I call my method on my object client, did the references generate automatically the code xml that he need, like the program soapUi does?
For example :
MyWebService.ImplClient webService = new MyWebService.ImplClient;
webService.Open();
webService.send(value1,
value2, etc...);
With soapui, if I choose the method send, I got a xml like :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webServices/">
<soapenv:Header/>
<soapenv:Body>
<web:send>
<!--Optional:-->
<param1>value1</param1>
<!--Optional:-->
<param2>value2</param2>
So, when I call my method send in c#, did the references will do the same as soapUi(like I show)?
I don't know very much if it works like this.
I'm asking this because I tried some code like Web Service without adding a reference? but there is not result.
Thank you.
Upvotes: 1
Views: 123
Reputation: 5161
Yes, one of the reasons we use tools like Visual studio is because it saves us from having to type in a lot of boring stuff, like xmls.
When you add a servicereference, it will create code for you enabling you to call the methods of your service very much as if you are calling methods on any other class.
You no longer have to worry about what your xml looks like, what is in your SOAP headers or envelope, etc.
Why don't you just give it a try and see if it works?
(Honestly, i used to have to create my own soap messages and I was amazed at the absence of code when i used a service reference in C# for the very first time :) )
Upvotes: 2