I'm using a contract first approach to build JAX-WS Webservices. The clients pick the wsdl and xsd resources from a client jar as specified in this SO answer - https://stackoverflow.com/a/18323853/775467 by using the wsdlLocation attribute.
Is it possible to do the same on the server side. i.e is it possible to use wsdls and referred xsds from a jar in sun-jaxws.xml
<endpoint name='TestService'
implementation='provider.server.AddNumbersImpl'
wsdl='WEB-INF/wsdl/Test.wsdl'
service='{http://example.org}TestService'
port='{http://example.org}TestServicePort'
url-pattern='/test'/>
I know that I can refer to wsdls in the WEB-INF directory as in the above snippet but I don't want to package the wsdls and xsds into the WAR but would like to pick them up from a shared library jar deployed to the server in the same way how the client code picks the wsdl.
There's no possibility to change the location of the wsdl file. The wsdl attribute at sun-jaxws.xml must have the prefix "WEB-INF/wsdl". Else JAX-WS generates and publishes a new WSDL. If you take a look at the source code of jaxws-ri, you can find the implementation at the class com.sun.xml.ws.transport.http.DeploymentDescriptorParser, method getPrimaryWSDL:
...
if (wsdlFile != null) {
if (!wsdlFile.startsWith(JAXWS_WSDL_DD_DIR)) {
logger.log(Level.WARNING, "Ignoring wrong wsdl={0}. It should start with {1}. Going to generate and publish a new WSDL.", new Object[]{wsdlFile, JAXWS_WSDL_DD_DIR});
return null;
}
...
}
Related
I have a wsdl and can create the server from it in various ways. But I need the wsdl generated by the web service is just like the original wsdl.
I have the .wsdl file and generate the .asmx file (for example using the wsdl.exe)
When caught the URL localhost/MyWS.asmx?wsdl the wsdl generated is not equal to the source.
It is possible that the wsdl is equal after the generated webservice?
I am using a wsdl file sent to me via email to generate a WS client application but I wonder if it is better to have the WSDL hosted on a server and to use an URL to request it.
Actually, I requested the URL but apparently this WSDL don't have one and I can ask to create an Url for the wsdl if it is really necessary.
Can you tell me please what are the benefits of using the WSDL Url to create a WS client ?
There is not difference for you how to generate WS client. In both cases this is just WSDL document, no matter where it located is.
I see only one benefit direct accessible WSDL against WSDL file - WSDL will be always actual and and all web service changes will be reflected to WSDL document.
If you using axis 2, you can try call your webservice with ?wsdl suffix to get WSDL document
if this your webservice url
http://localhost:8080/axis2/services/StockQuoteService
This is wsdl location
http://localhost:8080/axis2/services/StockQuoteService?wsdl
How can I expose a webservice keeping the original wsdl file?
I have a wsdl file and I generated the stub classes from that file, then I implemented the service, but when I deploy in my Weblogic server, the generated wsdl file is not the same as original wsdl file.
For example, the generated wsdl has different Binding name, Port name, xsd url changed, etc, and I need keep the original wsdl due to client request.
Is possible provide the original wsdl to jax-ws? I tried using the wsdllocation property from WebService annotation too, but it doesn't works.
I am using RAD 7.5 to generate WSDL from java service class using JAX-WS. My Server is WAS 7.0. I am not able to see any option in RAD to exclude the XSD generation and include the request & response type object details in WSDL itself.
Is this possible to create a WSDL file which will also hold the request & response object detail using JAX-WS? I dont want to have XSD file.
I am new to Web Service, please let me know if I am thinking something rubbish :)
Can any one please let me know what is the method to generate WSDL in Apache CXF Server using original WSDL.
I know Axis 2 has a configuration in Service.xml to set useOriginalWSDL to TRUE and I get the original wsdl.
I want to know the setting in CXF.
For using the original WSDL to generate WSDL in CXF Server we can use the attribute wsdlLocation in the element jaxws:endpoint
The attribute ,Specifies the location of the endpoint's WSDL contract. The WSDL contract's location is relative to the folder from which the service is deployed.
OR
in CXF we can use #WebService annotation we can specify the WSDL location Please refer the documentation
about #WebService
I myself found the answer, I think this is a simple question, but felt that this answer can be in stackoverflow
EDIT:
Eventhough I added wsdlLocation , the service could not be created by CXF framework. Errors in apache tomcat are not that helpful, except stating that Service could not be created.
For proper working jaxws:endpoint should have following attributes:
wsdlLocation - relative path from the project folder e.g /WEB-INF/originalwsdl.wsdl
serviceName - service name in the WSDL, with namespace specified in wsdl e.g e:ServiceName
endpointName - this is the port binding name, same rules as serviceName e.g e1:endpointName
Remember to define the namespaces for e: and e1 by xmlns:e="namespace as in your wsdl"
After all this setting my application worked.
The classes we create from wsdl should have the same package name as target name space, for creating exactly same WSDL using original WSDL. Please someone confirm this finding.
I found that there is very little documentation for CXF, and had to
dig in the code and xsds for my solutions