2013-06-27 2 views
0

Android에서 내 webservice 함수를 호출 할 때 매개 변수를 설정하는 데 문제가 있습니다. 그러나 웹에서는 제대로 작동합니다.ksoap2 - 요청 매개 변수가 null로 설정되었습니다.

<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> 

참고 :

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(); 
     } 

내가 제이 보스 내 서버를 탑재, 이것은 내가 다른 기능을 삭제하기위한 더 이해하게되는 내가 가지고있는 웹 서비스입니다 나는 내 서버 로그를 확인하고 그가 얻은 param은 null입니다 (이 함수는 call이지만 null을 사용합니다).

답변

1

다음과 같이 사용하십시오.

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
      request.addProperty("descripcion","hola."); 

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
envelope.setOutputSoapObject(request); 

HttpTransportSE ht = new HttpTransportSE(URL); 
ht.call(SOAP_ACTION, envelope); 

final SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 
final String str = response.toString(); 

Reference에 이것을 사용하십시오. 희망이 당신을 도울 것입니다.

+0

작동하지 않습니다. 모든 것이 정상이며 작동하지 않습니다. :(오류 코드가 숯 화일에 관한 것일 수 있습니까? –

+0

올바른 NAMESPACE, METHOD_NAME 및 SOAP_ACTION을 전달 했습니까? – Nirmal

+0

내가 무엇을했는지 알지 못하지만 지금은 작동하지 않습니다 .SObject 대신 SoapPrimitive를 변경해야합니다. 나는 좋은 대답으로 표시한다. 어쨌든 덕분에. –

관련 문제