How to change address location of JAX-WS webservice
Asked Answered
S

3

7

We have currently exposed JAX-RPC webservice with following URL

http://xx.xx.xx.xx/myservice/MYGatewaySoapHttpPort?wsdl

We migrated webservice to JAX-WS by generating WebService from above WSDL

But new webservice is accessible from following URL

http://xx.xx.xx.xx/myservice/MYGateway?wsdl

How i can make my JAX-WS webservice to be accessible by same URL mentioned first? so that our customer dont have any problem.

Update:

Service Element of WSDL from which i created is as per expectation

<WL5G3N0:service name="MyGateway">
    <WL5G3N0:port binding="WL5G3N2:MyGatewaySoapHttp" name="MyGatewaySoapHttpPort">
      <WL5G3N3:address location="http://xx.xx.xx/myservice/MyGatewaySoapHttpPort"/>
    </WL5G3N0:port>
  </WL5G3N0:service>

But WSDL of JAX-WS is not same and this WSDL is auto generated.

<WL5G3N0:service name="MyGateway">
- <WL5G3N0:port binding="WL5G3N2:MyGatewaySoapHttp" name="MyGatewaySoapHttpPort">
  <WL5G3N3:address location="http://xx.xx.xx/myservice/MyGateway" /> 
  </WL5G3N0:port>
 </WL5G3N0:service

I created webservice with Oracle Eclipse Indigo.

Can i change with any annotaion?

Regards,

Saturday answered 20/7, 2012 at 9:29 Comment(0)
S
2

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

Saturday answered 20/7, 2012 at 15:48 Comment(1)
The link doesn't work anymore. Can you describe your solution as it is the accepted answer.Scroll
S
18

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.

Slink answered 20/7, 2012 at 12:10 Comment(3)
Your provided Code will help client. But i want to change address of webservice at server. So there will be no changes at client side.Saturday
It seems that your tooling is generating a modified WSDL. You should check out the documentation o see if you can influence the location value it generates.Slink
Yes that what i am looking for how i can influence location value.Saturday
S
2

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

Saturday answered 20/7, 2012 at 15:48 Comment(1)
The link doesn't work anymore. Can you describe your solution as it is the accepted answer.Scroll
F
0

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

Forsook answered 20/7, 2012 at 9:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.