开发者

how to create soap client?

开发者 https://www.devze.com 2023-04-12 04:52 出处:网络
I have SOAP server running. I need to write a SOAP client for the server. Can you please suggest plugin in eclipse or give me the URL related to this?

I have SOAP server running. I need to write a SOAP client for the server. Can you please suggest plugin in eclipse or give me the URL related to this?

can you pl开发者_开发问答ease provide me it you have any sample SOAP Client code?

My SOAP client should use complex objects as parmeter/arguments for the SOAP function which is exposed in the SOAP server.


Assuming Java:

1.- Execute:

wsimport -keep -p myClient url_to_wsdl

Where myClient will be a folder with the generated client's artifacts. url_to_wsdl the url to your WSDL.

2.- Create a client class with a method with the following code:

    YourServiceClass service = new YourServiceClass();
    YourEndpointClass port = service.getPort();
    YourRequestClass request = new YourRequestClass();
    YourMessageClass message = new YourMessageClass(); //In case you have it
    message.setParam1(param1); //depending on your message
    message.setParam2(param2);

    request.setMessage(message);
    YourResponseClass response = port.ServiceOperation(request); //This call locks execution

    System.out.println(response.getMessage().getResponse());
  • YourServiceClass is the generated artifact the extends javax.xml.ws.Service.

  • YourEndpointClass can be seen in YourServiceClass in an operation that calls super.getPort();

  • YourRequestClass and YourResponseClass will depend on how is managed the Request and Response message.

  • YourMessageClass would be a wrapper class for your message (depending on WSDL).

All Your* classes must have been generated by wsimport and imported to your client class. With the flag -keep in wsimport you'll be able to see the .java files and determine which classes you require to complete this code.


Your question is very vague, so use Apache CXF and follow this tutorial:

  1. This is the most recent (2011) writeup: Creating a SOAP client with either Apache CXF or GlassFish Metro
  2. How to create a WSDL-first SOAP client in Java with CXF and Maven and
  3. This demo illustrates Apache CXF's support for SOAP headers

Other wise, you can also use Apache AXIS2.


here's a detailed tutorial on how you can create one : SOAP Client in Java


Update your eclipse to newest version (I have seen it working with Eclipse Europa 3.3.2 also though :) ). Go to new project wizard and under Web Service select Web Service Client, click next and then give wsdl file location of your web service. Eclipse will automatically generate web service stubs for you.


Thats pretty much a little bit broad question. From my point of view i would suggest using Apache CXF: http://cxf.apache.org/

There are pretty good samples and you define a WSDL and generate the server as well as the client code. There are also maven plugins which do this JOB automatically for you. Embedding an existent web-service described by an WSDL is also possible.

But however this is more a matter of requirements and taste.

Alternatives may be found e.g. here: http://java-source.net/open-source/web-services-tools


You can have a look at this --> https://github.com/devashish234073/SOAP_GUI_PHP/blob/master/README.md This is a simple SOAP client in php.

Using same logic as the php one [home.php], I have also added the java version

0

精彩评论

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