This relates specifically to .NET. And I've decided to use the Web service Reference instead of Web Service...I think though my questions below really are for either situation and I want to try to get the overall idea of this.
So here is the issue for me. Let me first explain where I'm coming from. One past projects, I've talked to a couple APIs before by creating manual classes such as a GetPicturesRequest.cs and a GetPicturesResponse.cs for example that would hold state for me. I'd have a base class called Request.cs that did the actual sending of the api call:
Stream requestStream;
Stream responseStream;
XmlDocument doc = new XmlDocument();
doc = CreateRequestXML();
// Determins if API call needs to use a session based URI
string requestURI = UseAuthURI == true ? _requestURIAuthBased + JSessionID : _requestURI;
byte[] data = XmlUtil.DocumentToBytes(doc);
// Create the atual Request instance
HttpWebRequest request = CreateWebRequest(requestURI, data.Length);
request.ContentLength = data.Length;
request.KeepAlive = false;
request.Timeout = 30000;
// Send the Request
requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
ok, but now I want to use a Web service Reference. So I pointed and created a new reference to https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl in VS 2008. I now have a Web Reference.
I have now these questions as being a first time user of web services as opposed to doing things manually as I was to use a 3rd party API:
1) How can I specify header params? For instance some APIs require you to send a hash (signature), sessionID, username, password, you name it along with the API method call request. How do you specify this using a web service proxy class?
2) How is the request/response objects handled or do I not need to worry about this now that I'm using a web service/reference? I mean do I need to create a request object still and how would I receive the response?
3) When I receive the response, does the PRoxy class contain its state or do I have to still create a class to hold the state of the returned data from the API method call response when using web services/references?
4) When ever would I want to instead just create custom code like I did before and not use web services/reference option with WSDL?...essentially creating my own proxy classes, request objects, response objects, everything? Rather than have VS spit out a Web Reference based on a WSDL? Is it because if it's not a SOAP based 3rd party API? Is it because the 3rd party API does not provide a WSDL then you're forced to hand code the wrappers yourself?
thanks.