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,
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
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
来源:https://stackoverflow.com/questions/11576615/how-to-change-address-location-of-jax-ws-webservice