0

我正在尝试在 Ksoap2 库的帮助下从我的 android 应用程序访问托管在 tomcat 服务器中的 JAX-WS Web 服务。当我运行该应用程序时,它在信封.bodyIn 调用中抛出了一个肥皂错误(打印 1.1 ;-)) .

在logcat中,我得到:找不到{http://titpl.com/service/UserLogon../}UserLogonOperation..的调度方法。

如果有人可以提供任何建议,我将不胜感激。

我的安卓代码:

private final String NAMESPACE ="http://titpl.com/service/UserLogon/";

private final String URL="http://10.0.2.2:8085/PrepaidMobileServer/UserLogonService?wsdl";

private final String SOAP_ACTION ="http://titpl.com/service/UserLogon/UserLogonOperation";

     final String METHOD_NAME = "UserLogonOperation";

    Login_Res login_res=new Login_Res();
    Log.i("WSC ACT", "inside the method");

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    PropertyInfo cardprop = new PropertyInfo();

    cardprop.setName("login_req");
    cardprop.setValue(login_req);
    cardprop.setType(Login_Req.class);


    request.addProperty(cardprop);

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

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        System.out.println(login_req.getNric());
        System.out.println(login_req.getPassword());
        System.out.println(request.getProperty("login_req"));
        androidHttpTransport.call(SOAP_ACTION, envelope);
        System.out.println("------------------------------1------------------------------");
        //get the response
        //SoapObject response = (SoapObject) envelope.getResponse();
        //SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        //SoapObject response = (SoapObject) envelope.bodyIn;

        if (envelope.bodyIn instanceof SoapFault) {
            String str= ((SoapFault) envelope.bodyIn).faultstring;
            Log.i("", str);
            System.out.println("------------------------------1.1-------------------------------");

        } else {
            SoapObject response  = (SoapObject) envelope.bodyIn;
            Log.d("WS", String.valueOf(response));
            System.out.println("------------------------------1.2-------------------------------");
            Log.i("WSC:UserLogonOperation", response.toString());
            login_res.setNric(response.getProperty(1).toString());
            login_res.setStatus(response.getProperty(2).toString());
            login_res.setDesc(response.getProperty(3).toString());

        }

    } catch (Exception e) {
        Log.i(" Exception in WSC:UserLogonOperation", e.toString());
        e.printStackTrace();
    }

我的 WSDL:

    <!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-740-.
-->
<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://titpl.com/service/UserLogon" xmlns:ns0="http://titpl.com/service/UserLogon/request" xmlns:ns1="http://titpl.com/service/UserLogon/response" name="UserLogon" targetNamespace="http://titpl.com/service/UserLogon">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://titpl.com/service/UserLogon/request" schemaLocation="http://localhost:8085/PrepaidMobileServer/UserLogonService?xsd=1"/>
<xsd:import namespace="http://titpl.com/service/UserLogon/response" schemaLocation="http://localhost:8085/PrepaidMobileServer/UserLogonService?xsd=2"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="GetUserLogonRequest">
<wsdl:part name="parameters" element="ns0:Login_Req"/>
</wsdl:message>
<wsdl:message name="GetUserLogonResponse">
<wsdl:part name="parameters" element="ns1:Login_Res"/>
</wsdl:message>
<wsdl:portType name="UserLogonPortType">
<wsdl:operation name="UserLogonOperation">
<wsdl:input name="GetUserLogonRequest" message="tns:GetUserLogonRequest"/>
<wsdl:output name="GetUserLogonResponse" message="tns:GetUserLogonResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UserLogonSoap" type="tns:UserLogonPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="UserLogonOperation">
<soap:operation soapAction=""/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UserLogonService">
<wsdl:port name="UserLogonPortType" binding="tns:UserLogonSoap">
<soap:address location="http://localhost:8085/PrepaidMobileServer/UserLogonService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

日志猫:

    0-18 07:28:30.817: I/WSC ACT(1872): inside the method
10-18 07:28:30.817: I/System.out(1872): ------------------------------1-------------------------------
10-18 07:28:31.197: I/System.out(1872): ------------------------------2-------------------------------
10-18 07:28:31.197: I/System.out(1872): as
10-18 07:28:31.197: I/System.out(1872): we
10-18 07:28:31.197: I/System.out(1872): com.android.beans.Login_Req@412d5d08
10-18 07:28:33.647: I/System.out(1872): ------------------------------3-------------------------------
10-18 07:28:33.647: I/(1872): Cannot find dispatch method for {http://titpl.com/service/UserLogon/}UserLogonOperation
10-18 07:28:33.647: I/System.out(1872): ------------------------------3.1-------------------------------
10-18 07:28:33.647: I/System.out(1872): ------------------------------4-------------------------------
10-18 07:28:33.647: I/System.out(1872): -----------------------------null-------------------------------
10-18 07:28:33.667: D/AndroidRuntime(1872): Shutting down VM
10-18 07:28:33.667: W/dalvikvm(1872): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
10-18 07:28:33.697: E/AndroidRuntime(1872): FATAL EXCEPTION: main
10-18 07:28:33.697: E/AndroidRuntime(1872): java.lang.NullPointerException
10-18 07:28:33.697: E/AndroidRuntime(1872):     at com.android.tiwallet.LoginActivity.onClick(LoginActivity.java:91)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.view.View.performClick(View.java:3511)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.view.View$PerformClick.run(View.java:14105)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.os.Handler.handleCallback(Handler.java:605)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.os.Looper.loop(Looper.java:137)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at android.app.ActivityThread.main(ActivityThread.java:4424)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at java.lang.reflect.Method.invokeNative(Native Method)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at java.lang.reflect.Method.invoke(Method.java:511)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
10-18 07:28:33.697: E/AndroidRuntime(1872):     at dalvik.system.NativeStart.main(Native Method)
10-18 07:28:34.237: I/dalvikvm(1872): threadid=3: reacting to signal 3
10-18 07:28:34.317: I/dalvikvm(1872): Wrote stack traces to '/data/anr/traces.txt'
10-18 07:28:36.847: I/Process(1872): Sending signal. PID: 1872 SIG: 9
4

2 回答 2

0

从你的网络服务,SOAP_ACTION 应该是这样的

    private final String SOAP_ACTION ="UserLogonPortType";
    // equal the line: <wsdl:portType name="UserLogonPortType">

代替

   private final String SOAP_ACTION ="http://titpl.com/service/UserLogon/UserLogonOperation";
于 2012-11-01T08:57:21.807 回答
0

尝试wsdl在 URL 中删除:

private final String URL="http://10.0.2.2:8085/PrepaidMobileServer/UserLogonService/"; 
于 2012-10-19T12:01:37.843 回答