我需要解析一个肥皂请求,但我遇到了以下问题,有人可以帮我解决这个问题,因为我是肥皂新手。如果您需要有关代码的任何其他信息,请告诉我
这是肥皂请求
POST /LocatorAPI/LocatorService.asmx HTTP/1.1
Host: staging2.abc.spatialpoint.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://spatialpoint.com/abc/locator/FindNearby"
<?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>
<FindNearby xmlns="http://spatialpoint.com/abc/locator/">
<request> <Token>string</Token>
</request>
</FindNearby>
</soap:Body>
</soap:Envelope>
这是我的目标 c 代码。
NSString* soapMessage =
[NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@",
@"<?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>",
@"<FindByProperty xmlns=\"http://spatialpoint.com/abc/locator/ \">",
@"<request>",
@"<Token>",
theRadius,
@"</Token>",
@"</request>",
@"</FindByProperty>",
@"</soap:Body>",
@"</soap:Envelope>"];
NSURL *url = [NSURL URLWithString:@"http://staging2.abc.spatialpoint.com/LocatorAPI/LocatorService.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
// HTTP headers
NSString *messageLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:messageLength forHTTPHeaderField:@"Content-Length"];
// method = POST
[req setHTTPMethod:@"POST"];
// BODY
[req setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
// send request
self.connection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (self.connection != nil)
{
self.receivedData = [NSMutableData data];
}
else
{
[[UIApplication sharedApplication]
setNetworkActivityIndicatorVisible:NO];
}
我得到了这个错误。
2013-06-19 02:22:49.942 SoapClient[42229:c07] Response:
2013-06-19 02:22:49.943 SoapClient[42229:c07] <?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault>
<faultcode>soap:Client</faultcode><faultstring>Server did not recognize the value of HTTP
Header SOAPAction: .</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>