2014-01-14 39 views
0

我需要一些幫助。 我不能訪問我的web服務,白衣的AndroidAndroid白皮書中沒有SOAPAction標題

我使用KSoap2 3.0.0,我與Android冰淇淋三明治工作4.0.3(API 15)

當我撥打服務我得到這個迴應:

<faultstring>no SOAPAction header!</faultstring> 

我告訴你我的代碼:

 public void service() 
{ 
     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

     Element[] headers = new Element[1];    
     Element element = new Element(); 
     element.setName(""); 
     element.setNamespace(NAMESPACE);   

     headers[0] = element; 


    envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12); 
    envelope.encodingStyle = SoapEnvelope.ENC; 
    envelope.setAddAdornments(false); 
    envelope.implicitTypes = true; 
    envelope.dotNet = false; 

    envelope.headerOut = headers; 

    envelope.setOutputSoapObject(request); 

    androidHttpTransport = new HttpTransportSE(URL); 
    androidHttpTransport.debug = true; 

    androidHttpTransport.call(SOAP_ACTION, envelope); 
    SoapObject resultsRequestSOAP = (SoapObject) envelope.body 
    } 

我展示的WSDL代碼的第一部分:

<wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" 
xmlns:impl="xxx.xxx.xxx:xxxx/xxxx/xxxx" xmlns:intf="xxx.xxx.xxx" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="xxx:xx.xxx.xxxx.xxxx.xx.xxxx.xx" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xxx.xxx.xxx.xxx:xxxx/xxxx/xxxxxxxx/xxxxxxxxx"> 

    <wsdl:types> 
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="xxx:xx.xxx.xxxx.xxxx.xx.xxxx.xx"> 
<import namespace="http://xxx.xxx.xxx.xxx:xxxx/xxxx/xxxxxxxx/xxxxxxxxx"/> 
<import namespace="http://xml.apache.org/xml-soap"/> 
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> 
<complexType name="SOCultivo">...</complexType> 
<complexType name="SOUser">...</complexType> 
<complexType name="SOInfoPaginacion">...</complexType> 
<complexType name="SOFinca">...</complexType> 
<complexType name="SOItem">...</complexType> 
<complexType name="SOEcotopo">...</complexType> 
<complexType name="SOAerofoto">...</complexType> 
<complexType name="SOInfoGeneral">...</complexType> 
<complexType name="SORespuestaWS">...</complexType> 
</schema> 

感謝所有幫助

回答

0
 Element element = new Element(); 
     element.setName(""); 

上面你上面的代碼,將創建一個空元素就像兩條線,

<></> 

現在你指定這個空元素到頭。

headers[0] = element; 

現在,當你也會調用

envelope.headerOut = headers; 

它將與此空元素取代你的肥皂頭。

如果要發送空頭,那麼你可以把它下面,

Element [] headers = new Element[1]; 
    headers[0]=new Element(); 

完蛋了,現在叫

envelope.headerOut = headers; 

它會創建空的肥皂頭一樣,

<soap:header></soap:header> 

如果你想在這個頭部添加少量節點,讓我知道你的頭部格式,我可以爲你提供代碼。