How to change address location of JAX-WS webservice

假如想象 提交于 2019-12-03 15:54:46
Adriaan Koster

This allows setting the endpoint in the client:

MYGateway service = new MYGateway();
MYGatewaySoapServiceHttpPort port = service=.getMYGatewaySoapServiceHttpPort();
BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(
    BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
    "http://xx.xx.xx.xx/myservice/MYGateway");

(thanks to user FoGH for pointing out that the endpoint should indicate the service, not the wsdl)

EDIT: here is some more information about setting up the org.codehaus.mojo.jaxws-maven-plugin:

In your pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>MyGateway</id>
            <goals>
                <goal>wsimport</goal>
            </goals>
            <configuration>
                <wsdlDirectory>src/main/resources/META-INF/wsdl</wsdlDirectory>
                <wsdlFiles>
                    <wsdlFile>MyGateway.wsdl</wsdlFile>
                </wsdlFiles>
                <wsdlLocation>MyGatewaySystemId</wsdlLocation>
                <!-- Line below to avoid regeneration bug if you have multiple executions -->   
                <staleFile>${project.build.directory}/jaxws/stale/wsdl.MyGateway.done</staleFile>
            </configuration>
        </execution>
    </executions>
</plugin>

In ./src/main/resources/META-INF/jax-ws-catalog.xml:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <system systemId="MyGatewaySystemId" uri="wsdl/MyGateWay.wsdl"/>
</catalog>

Put your WSDL in ./src/main/resources/META-INF/wsdl/MyGateway.wsdl

So the wsdlLocation in the plugin configuration refers to an entry in the jax-ws-catalog.xml file. This file points to the actual WSDL file using a relative directory notation.

The value 'MyGatewaySystemId' ends up in the generated web service code as the location. So you could change this to the actual URL of the WSDL. Note that you would need configure your pom to set the correct URL for the build environment (dev, test, prod) for this to work consistently. A pointer in the right direction for this is to use maven profiles.

Tip: an easy way to download a copy of an online WSDL (and related XSD's) is to create a SoapUI project for it and then go to the 'WSDL content' tab.

We missed very basic point, servlet mapping in web.xml did all trick. for details please find below link

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=%2Fcom.ibm.websphere.wsfep.multiplatform.doc%2Finfo%2Fae%2Fae%2Ftwbs_customwebxml.html

Check your Service element of your JAX-WS WSDL file.

<service name="Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding="tns:Hello_Binding" name="Hello_Port">
         <soap:address
            location="http://www.examples.com/SayHello/">
      </port>
   </service>

location element specifies through which port to access the Web service.

read this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!