简体   繁体   English

从Blackberry Eclipse项目错误中调用.NET Web服务

[英]Calling .NET web service from blackberry eclipse project error

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. 我只是想从我的BB应用程序中调用.net Web服务方法。 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). 但是,当我调用需要参数的方法(并在invoke()调用中传递这些参数)时,会得到相同的null响应(字符串和整数的默认值)。

the .net method that i am calling will simply return the values i passed to it. 我正在调用的.net方法将仅返回我传递给它的值。 so if i call the method "TestMe" with parm1 = "hello" and parm2 = "123", the response i should get is Hello. 因此,如果我用parm1 =“ hello”和parm2 =“ 123”调用方法“ TestMe”,我应该得到的响应是Hello。 Received ----> [parm1] hello [int1] 123. i can verify this response by simply calling the method through the WSDL via firefox. 收到----> [parm1]你好[int1]123。我可以通过通过Firefox通过WSDL调用该方法来验证此响应。

when i attempt to call the same method through the invoke() call, i get [parm1] [int1]0. 当我尝试通过invoke()调用调用同一方法时,我得到[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 integer types. 在我看来,.net方法似乎没有接收任何参数值,而只是返回字符串和整数类型的默认值。 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)? 因此,是否需要更改为.net Web服务以获得有效的响应,还是需要向Java代码中添加其他内容(对于BB应用程序)?

I am using eclipse as the editor, jdk1.16.0_017 as the JRE 我使用eclipse作为编辑器,使用jdk1.16.0_017作为JRE

import org.apache.axis.AxisFault; 导入org.apache.axis.AxisFault; import org.apache.axis.client.Call; 导入org.apache.axis.client.Call; import org.apache.axis.client.Service; 导入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. 假设您控制着Web服务,我强烈建议您使用Wireshark (或类似工具)查看请求和响应的外观-以及从浏览器尝试相同操作时的外观和效果,或者来自另一个Web服务客户端。

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. 我还将尝试通过一个简单的Java控制台应用程序执行相同的代码-在涉及Blackberry之前使其在此处运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM