gpt4 book ai didi

php - iOS:调用SOAP的PHP Web服务返回null

转载 作者:行者123 更新时间:2023-12-01 16:37:06 24 4
gpt4 key购买 nike

创建了一个扩展名为.php的Web服务,我正在通过soap传递参数。但是返回的结果是我无法理解的。我还要检查RestClient的输入是否正确,然后返回实际输出。这在代码中无法正常进行。可能出了什么问题?

我输入的xml结构是

<?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:Header>
</soap:Header>
<soap:Body>
<getUpdates>
<user_location></user_location>
<application_type>FC</application_type>
<last_updated_date>2014-11-25</last_updated_date>
<platform>Android</platform>
</getUpdates>
</soap:Body>
</soap:Envelope>

我的网络服务方法是
-(void) notifyDatacalled
{

NSString * post= @"<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:Header></soap:Header><soap:Body><getUpdates><user_location>new york</user_location><application_type>free</application_type><last_updated_date>2014-12-12</last_updated_date><platform>ios</platform></getUpdates></soap:Body></soap:Envelope>";


NSURL *url = [NSURL URLWithString:@"http://game.techone.com/webservices/service.php"];

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setTimeOutSeconds:30];
[request setDelegate:self];
[request setPostBody:[[post dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]];
[request addRequestHeader:@"Content-Type" value:@"text/xml"];
[request addRequestHeader:@"Content-Length" value:[NSString stringWithFormat:@"%d",[post length]]];
[request addRequestHeader:@"SOAPAction" value:@"getUpdates"];
[request setPostLength:[post length]];
[request setRequestMethod:@"POST"];
[request startSynchronous];

NSError *error = [request error];
if (error)
{

}
else
{
NSString *XmlResult = [NSString stringWithFormat:@"%@",[request responseString]];
NSDictionary *dictioneryResult = [XMLReader dictionaryForXMLString:XmlResult error:nil];
}
}

我得到的回应是
"SOAP-ENV:Envelope" =     {
"SOAP-ENV:Body" = {
"ns1:getUpdatesResponse" = {
return = {
"SOAP-ENC:arrayType" = "xsd:anyType[0]";
"xsi:type" = "SOAP-ENC:Array";
};
"xmlns:ns1" = "http://schemas.xmlsoap.org/soap/envelope/";
};
};
"SOAP-ENV:encodingStyle" = "http://schemas.xmlsoap.org/soap/encoding/";
"xmlns:SOAP-ENC" = "http://schemas.xmlsoap.org/soap/encoding/";
"xmlns:SOAP-ENV" = "http://schemas.xmlsoap.org/soap/envelope/";
"xmlns:xsd" = "http://www.w3.org/2001/XMLSchema";
"xmlns:xsi" = "http://www.w3.org/2001/XMLSchema-instance";
};

最佳答案

尝试添加

[request addRequestHeader:@"Accept" value:@"text/xml"];
到您的Web服务请求。您正在调用的REST服务默认为json。许多人经常应要求返回XML。

关于php - iOS:调用SOAP的PHP Web服务返回null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27243371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com