Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios soapxml中的问题_Ios - Fatal编程技术网

Ios soapxml中的问题

Ios soapxml中的问题,ios,Ios,我已经在iOS中实现了SOAP服务。 我正在使用以下代码发送请求 NSString *sSOAPMessage = @"<?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=\"h

我已经在iOS中实现了SOAP服务。 我正在使用以下代码发送请求

NSString *sSOAPMessage = @"<?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>"
    "<CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\">"
    "<Celsius>50</Celsius>"
    "</CelsiusToFahrenheit>"
    "</soap:Body>"
    "</soap:Envelope>";


NSURL *sRequestURL = [NSURL URLWithString:@"http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest *myRequest = [NSMutableURLRequest requestWithURL:sRequestURL];
NSString *sMessageLength = [NSString stringWithFormat:@"%d", [sSOAPMessage length]];

[myRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[myRequest addValue: @"http://www.w3schools.com/webservices/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"];
[myRequest addValue: sMessageLength forHTTPHeaderField:@"Content-Length"];
[myRequest setHTTPMethod:@"POST"];
[myRequest setHTTPBody: [sSOAPMessage dataUsingEncoding:NSUTF8StringEncoding]];

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

if( theConnection ) {
    webData = [[NSMutableData data] retain];
}else {
    NSLog(@"Some error occurred in Connection");

}
NSString*sSOAPMessage=@“”
""
""
""
"50"
""
""
"";
NSURL*sRequestURL=[NSURL URLWithString:@”http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest*myRequest=[NSMutableUrlRequestWithURL:sRequestURL];
NSString*sMessageLength=[NSString stringWithFormat:@“%d”,[SSOAP消息长度]];
[myRequest addValue:@“text/xml;charset=utf-8”用于HttpHeaderField:@“内容类型”];
[MyRequestAddValue:@”http://www.w3schools.com/webservices/CelsiusToFahrenheitforHTTPHeaderField:@“SOAPAction”];
[myRequest addValue:sMessageLength for HttpHeaderField:@“内容长度”];
[MyRequestSetHttpMethod:@“POST”];
[myRequest setHTTPBody:[sSOAPMessage dataUsingEncoding:NSUTF8StringEncoding];
NSURLConnection*连接=[[NSURLConnection alloc]initWithRequest:myRequest委托:self];
if(连接){
webData=[[NSMutableData]保留];
}否则{
NSLog(@“连接中发生了一些错误”);
}
我得到以下回应。没有得到任何值,例如,响应中的摄氏度或华氏度值。

现在检查它是否工作:

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"
"<CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\">    <Celsius>25.5</Celsius>                                                      </CelsiusToFahrenheit>"
"</soap:Body>\n"
"</soap:Envelope>\n"
];
NSLog(soapMessage);

NSURL *url = [NSURL URLWithString:@"http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit"];
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://www.w3schools.com/webservices/CelsiusToFahrenheit" 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");
}

您需要对其进行分析。

它将返回网页。使用一些HTML标记&spansI已经更改了它,但是现在服务器不会返回任何内容。嘿,谢谢你的回复。。。。它已开始工作并返回响应:)谢谢
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSString *data=[[NSString alloc]initWithFormat:@"%@",webData ];

//  NSLog(@"DONE. Received Bytes: %d, \n %@", [webData length],data);
    NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(@"Response is: %@",theXML);
}