Android ksoap2 svc?wsdl命名空间

时间:2019-03-14 16:31:10

标签: java web-services soap ksoap2 android-ksoap2

我正在编写一个需要4个参数的Android应用程序,并通过ksoap2使用wcf SOAP Web服务。

传递到Web服务的数据需要与从.Net发送的数据相匹配。

Java代码:

private static final String method_name = "PagoMovil.ConsultarArticulo";
// Namespace definido en el servicio web
private static final String name_space = "http://www.domain.mx/pagomovil/pagomovil/";
// namespace + metodo
private static final String soap_action  = "http://www.domain.mx/pagomovil/pagomovil/PagoMovil/ConsultarArticulo";
// Fichero de definicion del servcio web
private static final String wsdl_url  = "http://www.domain.mx/pagomovildev/PagoMovil.svc?wsdl";

 SoapObject soapObject =new SoapObject(name_space,method_name);

    PropertyInfo TipoArticulo = new PropertyInfo();
    TipoArticulo.setName("TipoArticulo");
    TipoArticulo.setValue("M");
    TipoArticulo.setType(String.class);

    soapObject.addProperty(TipoArticulo);

    PropertyInfo ClaveArticulo = new PropertyInfo();
    ClaveArticulo.setName("ClaveArticulo");
    ClaveArticulo.setValue("122-2");
    ClaveArticulo.setType(String.class);

    soapObject.addProperty(ClaveArticulo);

    PropertyInfo Usuario = new PropertyInfo();
    Usuario.setName("Usuario");
    Usuario.setValue("USUARIOS");
    Usuario.setType(String.class);

    soapObject.addProperty(Usuario);

    PropertyInfo Password = new PropertyInfo();
    Password.setName("Password");
    Password.setValue("CLAVES");
    Password.setType(String.class);

    soapObject.addProperty(Password);


    SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER10);
    envelope.dotNet=true;
    envelope.setOutputSoapObject(soapObject);
    HttpTransportSE httpTransportSE=new HttpTransportSE(wsdl_url);

    try {
        httpTransportSE.call(soap_action,envelope);
        SoapObject result=(SoapObject) envelope.bodyIn;

       String resultado= result.getProperty(0).toString();

    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e) {
        e.printStackTrace();
    }

这是Web服务需要工作的XML:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.domain.mx/pagomovil/pagomovil/PagoMovil/ConsultarArticulo</Action>
  </s:Header>
  <s:Body>
    <ConsultarArticulo xmlns="http://www.domain.mx/pagomovil/pagomovil">
      <pvRequest xmlns:d4p1="http://www.domain.mx/pagomovil/pagomovil" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
        <d4p1:TipoArticulo>M</d4p1:TipoArticulo>
        <d4p1:ClaveArticulo>122-2</d4p1:ClaveArticulo>
        <d4p1:Usuario>USUARIO</d4p1:Usuario>
        <d4p1:Password>CLAVE</d4p1:Password>
      </pvRequest>
    </ConsultarArticulo>
  </s:Body>
</s:Envelope>

我在Java中的代码返回“ anytype {}”而没有任何数据,我认为当我设置名称和值时,propertyinfo无法获取值。

如何构造代码以正确运行Web服务?

0 个答案:

没有答案