Objective c iOS-如何发出SOAP请求&;收到关注回复
我知道网络上有很多关于“如何在iOS中使用SOAP”的内容,但我仍然未能完成以下SAOP请求和响应。非常感谢您的帮助。 我使用简单的Objective c iOS-如何发出SOAP请求&;收到关注回复,objective-c,soap,nsurlconnection,Objective C,Soap,Nsurlconnection,我知道网络上有很多关于“如何在iOS中使用SOAP”的内容,但我仍然未能完成以下SAOP请求和响应。非常感谢您的帮助。 我使用简单的NSURLConnection进行请求和响应 肥皂需求 POST ???.asmx HTTP/1.1 Host: ??? Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/GetMessages" <?x
NSURLConnection
进行请求和响应
肥皂需求
POST ???.asmx HTTP/1.1
Host: ???
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetMessages"
<?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>
<GetMessages xmlns="http://tempuri.org/">
<GroupName>string</GroupName>
<Date>dateTime</Date>
</GetMessages>
</soap:Body>
</soap:Envelope>
我提到
&
我的问题是如何发送请求和接收问题回复
提前多谢了这个问题似乎与soap消息的发送/接收无关,而是与您作为
日期时间发送的值有关——它没有正确的格式
=>服务器无法处理请求。-->SqlDateTime溢出。必须在1753年1月1日12:00:00 AM和9999年12月31日11:59:59 PM之间
使用NSDateFormatter以请求的格式写入日期字符串。谢谢。。在格式化日期和时间后,它工作得非常好
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<GetMessagesResponse xmlns="http://tempuri.org/">
<GetMessagesResult>xml</GetMessagesResult>
</GetMessagesResponse>
</soap:Body>
</soap:Envelope>
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<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/\">\n"
"<soap:Body>\n"
"<GetMessages xmlns=\"http://tempuri.org/\">\n"
"<GroupName>%@</GroupName>\n"
"<Date>%@</Date>\n"
"</GetMessages>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"
, txtfield1.text
, textfield2.text
];
NSLog(@"soapMessage: \n%@",soapMessage);
NSURL *url = [NSURL URLWithString:@"???.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/GetMessages" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection )
webData = [[NSMutableData data] retain];
else
NSLog(@"theConnection is NULL");
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---> SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.</faultstring>
<detail />
</soap:Fault>