0

这是我的代码,它将尝试连接到我的网络服务......如何解决这个问题?您可以在此处查看我的 Web 服务示例代码:How to insert and get .NET web-service data Object to My Android App

        private static final String SOAP_ACTION = "http://www.mywesite.com/GetDetails";
        /* your webservice web method */
        private static final String METHOD_NAME1 = "GetDetails";
        private static final String NAMESPACE = "http://www.mywesite.com/";
        private static final String SOAP_ADDRESS = "http:///www.mywesite.com/webservice/service.asmx";
        String STR1 = "2F5B1900-07F6-0801-323B-0F10020B1803";

        //Code inside On-click
                SoapObject request = new SoapObject(NAMESPACE,
                        METHOD_NAME1);
    /*          PropertyInfo propertyInfo = new PropertyInfo();
                propertyInfo.type = PropertyInfo.STRING_CLASS;
                propertyInfo.name = "STR1";*/
                //use this to add parameters
                request.addProperty(METHOD_NAME1, STR1);
                //Declare the version of the SOAP request
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                        SoapEnvelope.VER11);
                envelope.dotNet = true;
                envelope.setOutputSoapObject(request);  

                try {
                    HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
                    //this is the actual part that will call the webservice
                    /*Here is some Problem*/
                    httpTransport.call(SOAP_ACTION, envelope);
                    // Get the SoapResult from the envelope body.
                    SoapObject resultGD=(SoapObject)envelope.bodyIn;
                    if(resultGD!=null)
                    {
                        System.out.println("The SOAP Object Received is: "+resultGD.getPropertyCount());
                        System.out.println("The SOAP Object Received is: "+resultGD.getProperty(0));
                    }
                    else
                    {
                        Toast.makeText(getApplicationContext(), "No Response", Toast.LENGTH_SHORT).show();
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }


While Executing this Code i'm Getting the Following Error:

        10-15 18:50:28.673: W/System.err(515): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@2:44 in java.io.InputStreamReader@44f65758) 
        10-15 18:50:28.673: W/System.err(515):  at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
        10-15 18:50:28.673: W/System.err(515):  at org.kxml2.io.KXmlParser.require(KXmlParser.java:1431)
        10-15 18:50:28.673: W/System.err(515):  at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
        10-15 18:50:28.684: W/System.err(515):  at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
        10-15 18:50:28.684: W/System.err(515):  at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
        10-15 18:50:28.684: W/System.err(515):  at com.tareta.FAM.FamHomePage.onClick(FamHomePage.java:128)
        10-15 18:50:28.684: W/System.err(515):  at android.view.View.performClick(View.java:2408)
        10-15 18:50:28.684: W/System.err(515):  at android.view.View$PerformClick.run(View.java:8816)
        10-15 18:50:28.684: W/System.err(515):  at android.os.Handler.handleCallback(Handler.java:587)
        10-15 18:50:28.693: W/System.err(515):  at android.os.Handler.dispatchMessage(Handler.java:92)
        10-15 18:50:28.693: W/System.err(515):  at android.os.Looper.loop(Looper.java:123)
        10-15 18:50:28.693: W/System.err(515):  at android.app.ActivityThread.main(ActivityThread.java:4627)
        10-15 18:50:28.693: W/System.err(515):  at java.lang.reflect.Method.invokeNative(Native Method)
        10-15 18:50:28.703: W/System.err(515):  at java.lang.reflect.Method.invoke(Method.java:521)
        10-15 18:50:28.703: W/System.err(515):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
        10-15 18:50:28.703: W/System.err(515):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
        10-15 18:50:28.703: W/System.err(515):  at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

0

在下面的行中删除“METHOD_NAME1”并添加 STR1 的密钥而不是那个。request.addProperty(METHOD_NAME1, STR1);

“STR1”应该是您的方法的参数打开 WSDL 并检查参数。

于 2012-10-15T13:56:00.633 回答