SOAP Messages on iPhone
I have to use several SOAP messages to get data from a web service. I got some examples how to do that but they all have the XML (http://icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/)
// ---- LOGIN -----
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<Login xmlns=\"http://tempuri.org/\">\n"
"<sUserID>USER</sUserID>\n"
"<sUserPw>PASSWORD</sUserPw>\n"
"<sDomain>SERVER</sDomain>\n"
"</Login>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n"
];
NSString *urlToSend = [[NSString alloc] initWithString:@"http://SERVER/DIRECTORY/WSDL_FILE.ASMX"];
NSString *callTOMake = [[NSString alloc] initWithString:@"http://WEBSERVER/Login"];
TWO questions: 1) Does it make sense to read the SOAP Message from a class or a file into xcode?? or sould I just define them thru the code ??
2) I used SOAPUI & .NET to query the service. It works fine... but when I do it from the iphone simulator it returns the following:
2010-03-10 15:13:54.773 Hello_SOAP[91204:207] soap:ClientServer did not rec开发者_开发技巧ognize the value of HTTP Header SOAPAction: http://WEBSERVER/DIRECTORY/Login
How can I figure out what the issue is that's causing the said error on the simulator??
OK... I have one solution for my issues...(#2) instead of writing the code and figuring if things will work by trial and error, I used Todd Ditchendorf SOAP Client http://code.google.com/p/mac-soapclient/
That way you can figure out what the SOAP call is a lot easier and just drop it on the code... BTW: you will get the pretty format of the request and response... that way you can format you lines of the code accordingly...
Hope this helps
精彩评论