2014-02-24 305 views
1

我試圖消耗SOAP web服務在Android和這樣做的編寫自己的代碼: 下面是我的代碼Android Unmarshalling錯誤:意外元素(URI:「url」,local:「scope」)。預計元素< {

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 &lt;{}rangeId>,&lt;{}scope>,&lt;{}commercialRef>,&lt;{}locale> 
</faultstring> 
</soap:Fault> 
</soap:Body> 
</soap:Envelope> 

我一直在試着修復它米3天並沒有成功。任何人都可以幫助修復它。我會很棒。 在soap ui中,wsdl工作正常。 在WSDL文件中的方法

<wsdl:message name="getXXXXXXXXX"> 
<wsdl:part element="tns:getProductDetailByCommercialRef" name="parameters" /> 

我已確認方法名,命名空間,網址我給了是正確的。 如果有人得到我所做的不正確的方式。請建議。

感謝, Android開發

回答

0

改變您的要求如下:

<soapenv:Envelope ... xmlns:ord="NAMESPACE"> 
... 
<ord:someMethodname> 
0

發送XML thorugh SOAP時,你必須包括

<![CDATA[ 
    <your xml items> 
    </your xml items> 
]]> 
相關問題