开发者

passing paramters using ksoap2 to .net web service, always passes nulls (empty) values

I'm having a problem in calling .net web services from android using ksoap2. The call is executed just fine without parameters, but when I pass paramters of any type, the web service just recieves a null value. I tried everything possible but no luck so far. I hope someone can help开发者_如何转开发, The client side code is:

 public static boolean temp(){
          try { 

           SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME_TEMP);
           PopertyInfo p = new PropertyInfo();
           p.type = PropertyInfo.INTEGER_CLASS;
           p.setName("num");
           p.setValue(5);
           p.setNamespace(NAMESPACE);
           request.addProperty(p)  ;
           SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11 );
           envelope.dotNet = true;
           envelope.encodingStyle = SoapSerializationEnvelope.ENC;
           envelope.setOutputSoapObject(request);
           AndroidHttpTransport  androidHttpTransport = new AndroidHttpTransport (URL);
           androidHttpTransport.call(SOAP_ACTION_TEMP, envelope);
     .....
             }

     .....


Just work fine for me in this way...

SoapObject requete = new SoapObject(NAMESPACE, METHOD_NAME);

PropertyInfo propertyInfo = new PropertyInfo();
propertyInfo.type = PropertyInfo.INTEGER_CLASS;
propertyInfo.name = "value";
requete.addProperty(propertyInfo, 2);

SoapSerializationEnvelope enveloppe = new SoapSerializationEnvelope(SoapEnvelope.VER11);
enveloppe.dotNet = true;
enveloppe.setOutputSoapObject(requete);

My Soap server is a WCF Service. Client is an android emulator using Ksoap..


I had this problem and i could resolve it. For resolving it you should consider the following setting:

my url was: "http://"+"MyIP:80/PathTraceWS/SetPathToServer.asmx" (I showed the url as above because of stackoverflow validation)

Web service action was : SetData

    String SOAP_ACTION= "http://"+"tempuri.org/SetData";
    String OPERATION_NAME="SetData";
    String WSDL_TARGET_NAMESPACE="http://"+tempuri.org/";
    String SOAP_ADDRESS="http://"+"192.168.1.54:80/PathTraceWS/SetPathToServer.asmx";

I believe if you set the above parameters correctly your problem will resolve. My problems were:

1- to set WSDL_TARGET_NAMESPACE to "http://"+"tempuri.org" not to "http://"+"tempuri.org/"

2- If you are calling web service by android mobile emulator you should not use localhost and instead you should use your system IP


If you have control over the webservice, try removing http:// from your namespace name in the webservice (and updating all your references in your java code). It's not a solution if it's not your own webservice that you're consuming (for that, you could try this workaround) but otherwise it seems to work fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜