0

Here is my Code which will try to connect to my web-service... How to Solve this issue?? You can see my web-service sample code here: 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)
Community
  • 1
  • 1
Saku
  • 180
  • 1
  • 3
  • 14

1 Answers1

0

In the line below remove "METHOD_NAME1" and add the key for the STR1 instead of that. request.addProperty(METHOD_NAME1, STR1);

"STR1" should be the parameter to your method open the WSDL and check the parameters for that.

andy
  • 208
  • 1
  • 7
  • request.addProperty(STR1, STR1); i tried it also but its giving system.err(1158) – Saku Oct 15 '12 at 14:17
  • Do you know WSDL? request.addProperty("KEY_FOR_FUNCTION_PARAMMETER","ACTUAL_VALUE_GOES_HERE") Suppose you are calling login_method then you will pass request.addProperty("username","xyz@gmail.com"); where "username" is the parameter name and "xyz@gmail.com" is its value.Hope this helps – andy Oct 15 '12 at 14:21
  • In my web-service method is type of DataSet so what type should i add in below code myPropInfo.setName("PDAID"); myPropInfo.setValue(PDAID); myPropInfo.setType(String.class); – Saku Oct 16 '12 at 08:13
  • Please provide details of the web-service.The service name and parameters. – andy Oct 18 '12 at 06:44
  • here is the link http://stackoverflow.com/questions/12893638/how-to-insert-and-get-net-web-service-data-object-to-my-android-app – Saku Oct 18 '12 at 08:45