|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Trouble with WOWebServiceClient invokeI'm consuming a WebService written with ASP.net that has a method that uses an 'out' parameter, i.e. of this form.
[WebMethod] int GetResultViaOutParam(out int out_param) I have no problems if the method has no 'out' parameters, i.e. of the form. [WebMethod] int GetResultWith2InParams(int param1, int param2) The WebObject code for the 'no out params' method is int arg1 = 3; int arg2 = 4; Object[] arguments = { new Integer(arg1), new Integer(arg2) }; String operation = new String("GetResultWith2InParams"); Object res = serviceClient().invoke(serviceName(), operation, arguments); The WebObject code for the 'out param' method is int arg1 = 0; Object[] arguments = { new Integer(arg1) }; String operation = new String("GetResultViaOutParam"); Object res = serviceClient().invoke(serviceName(), operation, arguments); The exception that is raised by the attempt to invoke 'WebMethodWithOutParam' is Error: Error invoking operation: javax.xml.rpc.JAXRPCException: Number of parameters passed in (1) does not match the number of IN/OUT parameters (0) from the addParameter() calls. How can I consume the 'GetResultViaOutParam' method? |
|
|
Re: Trouble with WOWebServiceClient invokeThese are steps I went through to get a WebObjects application to consume an ASP.net Web Service that has methods with 'out' parameters.
1. Use WSDL2Java to produce the necessary java files. Important thing to note is that classpath must be set, the syntax is java org.apache.axis.wsdl.WSDL2Java -cp <jar files> <WSDL-URL> The jar files I included were axis.jar commons_discovery.jar commons_logging.jar jaxrpc.jar log4j-1.2.8.jar saaj.jar wsdl4j.jar The WSDL-URL was the URL for my WebService. WSDL2Java produced a directory tree to match the Web Service and placed a bunch of java files in the tree. 2. Use NetBeans to produce a jar file. I used NetBeans 5.5.1. The project would not compile because the 'enum' keyword was introduced with JDK 1.5 and that was the default platform used and some of the java files use org.apache.axis.enum... This can be changed by right clicking on Libraries and selecting 'Properties - Manage Platforms - Add Platform', I selected 1.4.2 and then the home directory because it was marked with the 'contains JDK' icon. This is explained via the Help button. The build created a bunch of class files in the 'build/classes' directory and a jar file in the 'dist' directory. 3. Copy jar file to correct directory There must be a way of telling XCode where to look for packages referenced by 'import' directives, however I couldn't find one, I'd admit that I didn't try very hard to find one, so I just copied the jar file to '/Libraries/WebObjects/Extensions'. 4. Modify WebObject code These changes were derived from information in http://ws.apache.org/axis/java/user-guide.html#WSDL2JavaBuildingStubsSkeletonsAndDataTypesFromWSDL section 'WSDL2Java: Building stubs, skeletons, and data types from WSDL'. I added the import directives for the jar file. import com.ipv.WebService1; ... Service1 = service1 = new Service1Locator(); service1Soap soap = service1.getService1Soap(); IntHolder result = new IntHolder(); IntHolder arg1 = new IntHolder(); soap.getResultViaOutParam( result, arg1); And bingo it worked! NOTE - A few 'try' and 'catch' statements are needed but I omitted these for the sake of clarity.
|
| Free embeddable forum powered by Nabble | Forum Help |