在 iphone 中发出肥皂请求 [英] making a soap request in iphone

查看:25
本文介绍了在 iphone 中发出肥皂请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用只返回日期(测试)的soap web 服务.但是我无法连接到 Web 服务.我只从 Web 服务接收 wsdl,但我无法获得所需的数据.以下是我在目标 c 中的代码

I am trying to use a soap web service which only returns me a date(test). But I am not able to connect with the web service. I am only receiving the wsdl from the web service but I am not able to get desired data. Following is my code in objective c

 NSString *soapMessage = @"<?xml version="1.0" encoding="utf-8"?>
"
"<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
"
"<soap:Body>
"
"<getDate xmlns:type="xsd:string">
"
"</getDate>
"
"</soap:Body>
"
"</soap:Envelope>
";
NSURL *url = [NSURL URLWithString:@"http://10.1.6.5/gnosis2/public/wslogin/"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[req addValue:@"text/xml; charset=utf-8"  forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://10.1.6.5/gnosis2/public/wslogin/" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];

我想使用 Web 服务中的 getDate 方法.有人可以帮我吗?

I want to use getDate method from the web service. can some one please help me?

编辑
上面的代码给了我下面的 xml,与在浏览器中查看的 wsdl 相同:

Edit
The above code gives me following xml which is same as wsdl viewed in browser:

<?xml version="1.0"?><definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://10.1.6.5/gnosis2/public/wslogin/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="MyWebService" targetNamespace="http://10.1.6.5/gnosis2/public/wslogin/"><types><xsd:schema targetNamespace="http://10.1.6.5/gnosis2/public/wslogin/"/></types><portType name="MyWebServicePort"><operation name="getDate"><documentation>Get the server date and time</documentation><input message="tns:getDateIn"/><output message="tns:getDateOut"/></operation><operation name="getAgeString"><documentation>Get a nicely formatted string of a person's age</documentation><input message="tns:getAgeStringIn"/><output message="tns:getAgeStringOut"/></operation></portType><binding name="MyWebServiceBinding" type="tns:MyWebServicePort"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="getDate"><soap:operation soapAction="http://10.1.6.5/gnosis2/public/wslogin/#getDate"/><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.6.5/gnosis2/public/wslogin/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.6.5/gnosis2/public/wslogin/"/></output></operation><operation name="getAgeString"><soap:operation soapAction="http://10.1.6.5/gnosis2/public/wslogin/#getAgeString"/><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.6.5/gnosis2/public/wslogin/"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.6.5/gnosis2/public/wslogin/"/></output></operation></binding><service name="MyWebServiceService"><port name="MyWebServicePort" binding="tns:MyWebServiceBinding"><soap:address location="http://10.1.6.5/gnosis2/public/wslogin/"/></port></service><message name="getDateIn"/><message name="getDateOut"><part name="return" type="xsd:string"/></message><message name="getAgeStringIn"><part name="name" type="xsd:string"/><part name="age" type="xsd:int"/></message><message name="getAgeStringOut"><part name="return" type="xsd:string"/></message></definitions>

谢谢
潘卡伊

推荐答案

请通过以下链接http://www.icodeblog.com/2008/11/03/iphone-programming-tutorial-intro-to-soap-web-services/

希望能帮到你.

这篇关于在 iphone 中发出肥皂请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆