Objective-C:通过php Web服务发送/接收Iphone的SOAP


Objective-C: send/recieve SOAP for Iphone with php webservice

我几天前开始用Objective-C编程,所以我还是个初学者,也从来没有做过Web服务。因此,在一些教程的帮助下,我用php制作了一个Web服务。php文件如下所示:

<?php
function name($a){
$db = "app";
$verbindung = mysql_connect("localhost", "******", "******");
mysql_select_db($db);
$zeile = mysql_fetch_array(mysql_query("SELECT * FROM player Where Player_ID like $a"));
mysql_close();
return $zeile[1];           
}
$server=new SoapServer("profil.wsdl");
$server->addFunction("name");
$server->handle();
?>

我还得到了一个wsdl文件。

当我在这里测试我的Web服务时:http://www.soapclient.com/soaptest.html我得到以下回复:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:profil" xmlns:xsd="http://www.w3.org/2001/XMLSchema"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-  ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP- ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:nameResponse>
<Result xsi:type="xsd:string">Test123</Result>
</ns1:nameResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Result Test123正是我想在Objective-C程序中作为字符串得到的,但我不知道如何做到。我已经查看了很多教程,但我没有得到。我只需要发布1个int值,然后取回我的字符串:"Test123"。

我希望有人能帮助我,那太好了。

iOS中没有现成的方式与SOAP服务通信。实际上,这是不推荐的。您可以尝试wsdl2objc库,但我不建议使用SOAP服务。使您的服务与JSON一起工作,您将能够轻松地对其进行序列化/反序列化。