我正在尝试在SOAP
中使用Android
个网络服务并编写自己的代码:
以下是我的代码
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addSoapObject(getScopeBean());
request.addSoapObject(getLocaleBean());
request.addProperty("commercialRef","somevalidvalue" );
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
String xsd = envelope.XSD;
Log.e("envelop ", xsd);
envelope.setOutputSoapObject(request);
envelope.implicitTypes = true;
envelope.setAddAdornments(false);
HttpTransportSE http = new HttpTransportSE(URL, 2000);
http.call(SOAP_ACTION, envelope);
String requestDump = http.requestDump;
Log.e("requestDump", requestDump);
String responseDump = http.responseDump;
Log.e("responseDump", responseDump);
我的请求xml是
<?xml version="1.0"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:v="http://schemas.xmlsoap.org/soap/envelope/" >
<v:Header /><v:Body>
<someMethodname xmlns="NAMESPACE" >
<scope>
<brand>
somevalidname
</brand>
<country>
WW
</country>
<project>
somevalidname
</project>
</scope>
<locale>
<isoCountry>
GB
</isoCountry>
<isoLanguage>en</isoLanguage>
</locale>
<commercialRef>somevalidname</commercialRef>
</getProductDetailByCommercialRef>
</v:Body>
</v:Envelope>
并且回复是
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body><soap:Fault><faultcode>soap:Client</faultcode>
<faultstring>
Unmarshalling Error: unexpected element
(uri:"http://", local:"scope").
Expected elements are <{}rangeId>,<{}scope>,<{}commercialRef>,<{}locale>
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
我一直试着修复它3天但没有成功。任何人都可以帮忙解决它。我会很棒。 在肥皂ui中,wsdl工作正常。 在wsdl文件中的方法
<wsdl:message name="getXXXXXXXXX">
<wsdl:part element="tns:getProductDetailByCommercialRef" name="parameters" />
我已经确认了我给出的methodname,namespace,url是正确的。 如果有人得到我正在做的不正确的方式。请建议。
谢谢, Android开发人员
答案 0 :(得分:0)
将您的请求更改为以下内容:
<soapenv:Envelope ... xmlns:ord="NAMESPACE">
...
<ord:someMethodname>
答案 1 :(得分:0)
发送xml thorugh SOAP时,你必须包括
<![CDATA[
<your xml items>
</your xml items>
]]>