我需要一些帮助。 我无法访问我的网络服务,whit android
我正在使用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 :(得分:0)
Element element = new Element();
element.setName("");
上面代码中的两行以上,将创建一个空元素,如
<></>
现在您要将此空元素分配给标题。
headers[0] = element;
现在你打电话给
envelope.headerOut = headers;
它会用这个空元素替换你的soap标题。
如果您想发送空标题,那么您可以按照以下方式进行,
Element [] headers = new Element[1];
headers[0]=new Element();
多数民众赞成,现在正在致电
envelope.headerOut = headers;
它将创建空的肥皂标题,如
<soap:header></soap:header>
如果你想在这个标题中添加几个节点,请告诉我你的标题格式,我可以为你提供代码。