使用复杂类型在Android中进行Web服务调用时出错

时间:2014-09-20 18:46:12

标签: android web-services ksoap2

我在Android中的网络服务有问题。我发送一个ASP.Net应用程序的调用,我的应用程序没有收到良好的响应。 我有一个类似的代码来调用另一个使用字符串并且工作正常的方法,但是这个调用使用复杂类型而且不起作用。

我希望收到一个字符串,但实际上我收到一个异常:System.Web.Services.Protocols.SoapException:服务器无法处理请求---> System.ArgumentNullException:值不能为null。

我使用Ksoap2库。

这是我的班级:

package docService;

import java.util.List;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import andro.util.Log;
import com.sistems.doc.EnviarArchivo;

public class CallSoapNew extends Thread {

public final String SOAP_ACTION = "http://myweb.com/doc/AppendNew";

public final String OPERATION_NAME = "AppendNew";

public final String WSDL_TARGET_NAMESPACE = "http://myweb.com/doc";

public final String SOAP_ADDRESS = "http://myweb.com/Service.asmx";

public vo run() {
    try {
        String resp = Call(EnviarArchivo.documentalTyped,
                EnviarArchivo.values, EnviarArchivo.hypValues,
                EnviarArchivo.ocLogin, EnviarArchivo.controlInfo,
                EnviarArchivo.ip);
        EnviarArchivo.result = resp;
    } catch (Exception ex) {
        EnviarArchivo.result = ex.toString();
    }
}


public String Call(String documentalTyped, List<String> values,
        List<String> hypValues, String ocLogin, String controlInfo,
        String ip) {
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,
            OPERATION_NAME);
    PropertyInfo pi = new PropertyInfo();
    pi.setName("documentalTyped");
    pi.setValue("847632423876");
    pi.setType(String.class);
    request.addProperty(pi);


    SoapObject object = new SoapObject(WSDL_TARGET_NAMESPACE, "values");
    object.addProperty("Column", "38d192861");
    object.addProperty("Value", "nombreeterte");
    request.addSoapObject(object);


    SoapObject obj = new SoapObject(WSDL_TARGET_NAMESPACE, "hypValues");
    obj.addProperty("Column", "38d192861");
    obj.addProperty("Url", "nombreeterte");
    obj.addProperty("Alternative", "nrtyrtyrtyrtyrrte");
    obj.addProperty("Title", "nomette");
    obj.addProperty("Ijmg", "ntterterterte");
    request.addSoapObject(obj);

    pi = new PropertyInfo();
    pi.setName("ocLogin");
    pi.setValue(ocLogin);
    pi.setType(String.class);
    request.addProperty(pi);


    pi = new PropertyInfo();
    pi.setName("controlInfo");
    pi.setValue("hghg");
    pi.setType(String.class);
    request.addProperty(pi);

    pi = new PropertyInfo();
    pi.setName("ip");
    pi.setValue("321563");
    pi.setType(String.class);
    request.addProperty(pi);

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

    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
    Object response = null;

    httpTransport.debug = true;

    try {
        httpTransport.call(SOAP_ACTION, envelope);
        response = envelope.getResponse();
    } catch (Exception exception) {
        response = exception.toString();
    }
    return response.toString();
}

}

这是内容变量httpTransport的XML:

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
    <v:Body>
        <n0:AppendNew ="o0" c:root="1" xmlns:n0="http://myweb.com.com/doc">
            <documentalTyped i:type="d:string">847632423876</documentalTyped>
            <n0:values i:type="n0:values">
                <Column i:type="d:string">38d192861</Column>
                <Value i:type="d:string">nombreeterte</Value>
            </n0:values>
            <n0:hypValues i:type="n0:hypValues">
                <Column i:type="d:string">38d192861</Column>
                <Url i:type="d:string">nombreeterte</Url>
                <Alternative i:type="d:string">nrtyrtyrtyrtyrrte</Alternative>
                <Title i:type="d:string">nomette</Title>
                <Ijmg i:type="d:string">ntterterterte</Ijmg>
            </n0:hypValues>
            <ocLogin i:type="d:string">jhbb77fd2</ocLogin>
            <controlInfo i:type="d:string">hghg</controlInfo>
            <ip i:type="d:string">321563</ip>
            </n0:AppendNew>
        </v:Body>
</v:Envelope>

这是我收到的XML:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
    <soap:Fault>
    <faultcode>soap:Server</faultcode>
    <faultstring>System.Web.Services.Protocols.SoapException: El servor no puede procesar la solicitud. ---&gt; 
System.ArgumentNullException: El valor no puede ser nulo.\r\n
Nombre del parámetro: g\r\n   en System.Gu..ctor(String g)\r\n   
en CommonService.CheckSession(String user, String ip, ocSessionType ocSessionType)\r\n   
en ocService.AppendNewLdapUser(String documentalType, List`1 values, List`1 hypValues, String ocLogin, String userLogin, String ldapUser, String controlInfo, String ip)\r\n   
en ocService.AppendNew(String documentalType, List`1 values, List`1 hypValues, String ocLogin, String controlInfo, String ip)\r\n   
--- Fin del seguimiento de la pila de la excepción interna ---
    </faultstring>
    <detail />
    </soap:Fault>
    </soap:Body>
</soap:Envelope>

任何人都可以帮助我吗?谢谢

0 个答案:

没有答案