Server not able to read parameters while making a webservice connection

主宰稳场 提交于 2019-12-18 09:47:27

问题


I am connecting to .net webservice using below code,i am able to connect and get incomplete response from server.I am adding userId has parameter with '1' has value of type string.The issue is 'server is not able to read the parameters at all i am sending in request' .I am not sure if something is wrong on my side.I have attached the webservice request and response and my code.

and my android connecting code

private class AsyncCallWS extends AsyncTask<String, Void, Void> {
        @Override
        protected Void doInBackground(String... params) {
            //Invoke webservice
        displayText=WebService.invokeHelloWorldWS(editText,"GetReminder");
        return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            //Set response
            tv.setText(displayText);
            //Make ProgressBar invisible
            pg.setVisibility(View.INVISIBLE);
        }

        @Override
        protected void onPreExecute() {
            //Make ProgressBar invisible
            pg.setVisibility(View.VISIBLE);
        }

        @Override
        protected void onProgressUpdate(Void... values) {
        }

    }

webservice called here.

public class WebService {
    //What is the Namespace of the Webservice ??
    private static String NAMESPACE = "http://tempuri.org";
    //Webservice URL
private static String URL = "http://1.3.44.5:8080/csmmobileapi/service.asmx";
    //SOAP Action URI ???
    private static String SOAP_ACTION = "http://tempuri.org/GetReminder";
    private  static final String TAG=null;
    public static String invokeHelloWorldWS(String name, String webMethName)  
{
        boolean result=false;
        String resTxt = null;
        // Create request
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        SoapObject request = new SoapObject(NAMESPACE, webMethName);
        envelope.setOutputSoapObject(request);
        androidHttpTransport.debug=true;
        // Property which holds input parameters
        PropertyInfo sayHelloPI = new PropertyInfo();
        // Set Name
        sayHelloPI.setName("UserId");
        // Set Value
        sayHelloPI.setValue("1");
        // Set dataType
        sayHelloPI.setType(String.class);
        // Add the property to request object
       request.addProperty(sayHelloPI);
        //Set envelope as dotNet
        envelope.dotNet = true;
        try {
            // Invoke web service
            androidHttpTransport.call(SOAP_ACTION, envelope);
            // Get the response
            String response=androidHttpTransport.responseDump;
            Log.d("Result --- ", response.toString() );
           //tried with SoapObject and SoapPrimitive
            SoapObject obj=(SoapObject)envelope.getResponse();
            Log.d("Result --- ", obj);
            System.out.println("obj---->" + obj.toString());
}

回答1:


Did a very silly mistake,i found out after doing so much trial n error work.., private static String NAMESPACE = "http://tempuri.org"; changed to private static String NAMESPACE = "http://tempuri.org/"; and everything worked well.



来源:https://stackoverflow.com/questions/29215730/server-not-able-to-read-parameters-while-making-a-webservice-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!