简体   繁体   中英

Java's answer to PHP's SoapClient()?

There's a lot of information out there, but I can't quite figure out: What's Java's answer to PHP's SoapClient()?

No frills, just want to create a client to access the methods described by a .wsdl document.

JAX-WS, most appserver vendors supply implementations and tooling.

See glassfish for an exmple implementation. The glassfish guide docs give details of how to go about developing, there are many variations depending upon how you would normally go about doing Java development. For me, I work with IBM tools and therefore simply load up RAD point as the WSDL and click "generate".

See this question . There are many Web Services frameworks in Java that can generate a client from a WSDL file. Eclipse has a plug-in to create a client stub from a WSDL file using the Axis2 framework. Perhaps this is the easiest option for a beginner.

If all you want is a piece of software to generate client code from an existing WSDL, you have more options than you can shake a stick at. I've tried several, and they all do pretty much the same thing in the same way, the big difference between them being the documentation. For me, the best documented of the lot is Apache CXF , which will generate JAX-WS-compliant code that you can then use with any JAX-WS library in your application (such as CXF itself, or Sun's JAX-WS-RI, and so on).

It's going to be more complex than SoapClient, I would imagine.

You can try using RCPServiceClient class in axis2.

Here is the java doc for it: ws.apache.org/axis2/1_1_1/api/org/apache/axis2/rpc/client/RPCServiceClient.html

It doesn't require you to generate code to call web services.

Here is a decent example of how you can interact with a service using RPCServiceClient.

ws.apache.org/axis2/1_2/pojoguide.html#testingpojows

Do remember that java is strongly typed language so you can't do things like serviceClient->someRandomFunction(params), since someRandomFunction will not be defined ahead of time if you are trying to do something like PHP's SoapClient.

However, it will be equivalent to $soapClient->_soapCall function, as you will be able to do something like serviceClient.invokeBlocking( opProcess, -- function you are trying to call.. opResponseArgs, -- these are arguments you are passing returnTypes); -- types that you are expecting back

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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