开发者

How to generate non-secure stubs in Axis2 using wsdl2java

开发者 https://www.devze.com 2023-01-31 05:30 出处:网络
I am attempting to learn Axis2 Web Services, and am working through a tutorial on RoseIndia web site (link text).In the example for the client, it generates the stubs using wsdl2java, and it generates

I am attempting to learn Axis2 Web Services, and am working through a tutorial on RoseIndia web site (link text). In the example for the client, it generates the stubs using wsdl2java, and it generates the stubs which use http://localhost:8080, however, when I do it, it creates the stubs to use the secure links https://localhost:8443. I have not installed S开发者_Go百科SL onto my local dev app server (Tomcat).

I have checked the wsdl2java documentation and can't find any reference to security settings. How would I make these stubs use the basic http://localhost:8080 references


Look at your WSDL file. In Axis2 1.5 the wsdl2java tool will use this SOAP1.2 port to generate the target endpoint for your stub:

<wsdl:port name="HelloWorldServiceHttpSoap12Endpoint" binding="ns:HelloWorldServiceSoap12Binding">
  <soap12:address location="http://localhost:8082/axis2/services/HelloWorldService.HelloWorldServiceHttpSoap12Endpoint/" />
</wsdl:port>

You can use the -pn option of wsdl2java if you need to use another port.

Download your WSDL locally and verify that the port section is correct (no https). Further generate the sources with wsdl2java, e.g. on my machine:

lucho@lucholinuxpc:~/axis2-1.5.1/bin> ./wsdl2java.sh -uri /home/lucho/sayhello.wsdl
 Using AXIS2_HOME:   /home/lucho/axis2-1.5.1
 Using JAVA_HOME:       /opt/jdk1.6.0_18
 Using JAVA_OPTS:    -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Retrieving document at '/home/lucho/sayhello.wsdl'.

Now check your generated stub, you should see something like this in case your WSDL looks like mine:

/**
 * Default Constructor
 */
public HelloWorldServiceStub() throws org.apache.axis2.AxisFault {
        this("http://localhost:8082/axis2/services/HelloWorldService.HelloWorldServiceHttpSoap12Endpoint/" );
}

Next, in your test code you may alternatively use a constructor for your stub that takes the target endpoint. Actually I prefer this approach because the WS client is more flexible to changes in the target network. For your question should be something like:

public HelloWorldServiceStub(java.lang.String targetEndpoint)

And last but not least I recommend you this book for quick start-up tutorial SOAP Attachments using apache axis2

Cheerz!

0

精彩评论

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