开发者

Calling .NET web service from blackberry eclipse project error

开发者 https://www.devze.com 2022-12-18 02:26 出处:网络
i can\'t seem to figure what i\'m doing wrong. i am simply trying to call a .net web service method from my BB application. when i call a method that DOES NOT require parameters, i get a valid string

i can't seem to figure what i'm doing wrong. i am simply trying to call a .net web service method from my BB application. when i call a method that DOES NOT require parameters, i get a valid string response and everyone is happy. however, when i call a method that requires parameters (and i pass those parameters within the invoke() call), i get the same null response (default values for a string and integer).

the .net method that i am calling will simply return the values i passed to it. so if i call the method "TestMe" with parm1 = "hello" and parm2 = "123", the response i should get is Hello. Received ----> [parm1] hello [int1] 123. i can verify this response by simply calling the method through the WSDL via firefox.

when i attempt to call the same method through the invoke() call, i get [parm1] [int1]0.

to me, it seems that the .net method is not receiving any parameter values and is simply returning the default values for a string and int开发者_如何学Pythoneger types. so, is there something that i need to change to the .net web service to get a valid response or do i need to add something else to the java code (for my BB app)?

I am using eclipse as the editor, jdk1.16.0_017 as the JRE

import org.apache.axis.AxisFault; import org.apache.axis.client.Call; import org.apache.axis.client.Service;

String endpoint = "http://[SERVER]/wsBB/clsMyFunctions.asmx?WSDL";
String methodName = "TestMe";
String actionURI = "http://www.blahblahblah.com/TestMe";

 // set a SOAP call
 try {
   Service service = new Service();
   Call call = (Call) service.createCall();
   call.setTargetEndpointAddress( new java.net.URL( endpoint ) );
   call.setUseSOAPAction(true);
   call.setSOAPActionURI(actionURI);            
   call.setOperation(methodName);
   String ret = (String) call.invoke( new Object[]{"Hello!","1234"} );

   System.out.println("Sent 'Hellooooooooooo!', got '" + ret + "'"); 
 }
 catch( AxisFault af ) {
   System.out.println("dump: "+ af.dumpToString());
 }
 catch(Exception e)
 {
  System.out.println("EXCPETION: "+ e.toString());
 }


Assuming you're in control of the web service, I strongly recommend that you use Wireshark (or something similar) to see what the request and response look like - and what they're like when you try the same thing from a browser, or from another web service client.

That way you should get some indication of whether the problem is with the request or the response, and the nature of that problem.

I'd also try the same code from a simple Java console app - get it working there before getting the Blackberry involved.

0

精彩评论

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

关注公众号