我有一个 ASP.Net 网络服务,它可以从 iPhone SOAP 代码或另一个 .Net 客户端完美调用。但是,当我尝试使用 Ksoap2 时,未设置传递给服务的参数。在服务中,不能传入参数“AuthenticationID”,因为 WebMethod 所做的第一件事是检查字符串是否为空或空并返回“AuthenticationFailure”响应。我确实得到了响应,所以我知道 SOAP 的东西很好,只是参数没有被传递。
public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL) throws IOException, XmlPullParserException {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("AuthenticationID", "5");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
httpTransport.debug = true;
httpTransport.call(SOAP_ACTION, envelope);
SoapObject result=(SoapObject)envelope.getResponse();
return result;
}
WSDL 如下所示:
<?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>
<LookupStores xmlns="http://blah.com/Services/">
<AuthenticationID>string</AuthenticationID>
<NameMatch>string</NameMatch>
</LookupStores>
</soap:Body>
</soap:Envelope>
请给我一些东西来尝试这只是一个简单的服务,我认为使用 KSoap2 很容易使用。谢谢!