0
我有一個問題,當我從Android調用我的web服務功能時設置參數,但是在web中它工作正常。ksoap2 - 請求參數設置爲空
private static String URL="http://1.2.3.4:8080/Servidor/servicioTraducir?wsdl";
private static final String METHOD_NAME = "obtenerURL";
private static final String NAMESPACE = "http://servicioTraducir/";
private static final String SOAP_ACTION ="servicioTraducirService";
.
.
.
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("descripcion","hola.");
//I tried with it too:
//PropertyInfo texto = new PropertyInfo();
//texto.setName("descripcion");
//texto.setValue("hola.");
//texto.setType("string".getClass());
//request.addProperty(texto);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transporte = new HttpTransportSE(URL);
transporte.debug = true;
try {
transporte.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject)envelope.getResponse();
String res = result.toString();
urlResult = res;
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
我安裝我的JBoss服務器,這是web服務,我有我從中刪除等功能爲使其更容易理解:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://servicioTraducir/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="servicioTraducirService" targetNamespace="http://servicioTraducir/">
<types>
<xs:schema xmlns:tns="http://servicioTraducir/" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://servicioTraducir/" version="1.0">
<xs:element name="obtenerURL" type="tns:obtenerURL"/>
<xs:complexType name="inicializarResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:boolean"/>
<xs:complexType name="obtenerURL">
<xs:sequence>
<xs:element minOccurs="0" name="descripcion" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="obtenerURLResponse">...</xs:complexType>
</xs:schema>
</types>
<message name="servicioTraducir_obtenerURL">
<part element="tns:obtenerURL" name="obtenerURL"/>
</message>
<portType name="servicioTraducir">
<operation name="obtenerURL" parameterOrder="obtenerURL">
<input message="tns:servicioTraducir_obtenerURL"/>
<output message="tns:servicioTraducir_obtenerURLResponse"/>
</operation>
</portType>
<binding name="servicioTraducirBinding" type="tns:servicioTraducir">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="obtenerURL">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="servicioTraducirService">
<port binding="tns:servicioTraducirBinding" name="servicioTraducirPort">
<soap:address location="http://......:8080/Servidor/servicioTraducir"/>
</port>
</service>
注意:我檢查我的服務器日誌和他得到的參數是null(該函數是調用,但爲空)。
它不工作,一切都很好,它不起作用。 :(這可能是錯誤是關於字符編碼? –
你傳遞正確的NAMESPACE,METHOD_NAME和SOAP_ACTION? – Nirmal
我不知道我做了什麼,但它現在工作哈哈我必須改變SoapPrimitive而不是SObject。我標記爲好回覆。 –