Can the format of the URL for an Axis2 web service be configured when using the code-first approach (where Axis2 is generating the URL)? In particular, we would like to leave the port name out of the URL.
We have a web service that was built with Axis2 using the code-first approach. That means the WSDL is generated from the Java classes and their annotations.
The web service URL is currently:
http://www.example.com/services/AvailabiltyService.AvailabilityServicePort
But we would like the URL to be shortened to:
http://www.example.com/services/AvailabiltyService
The <service> element of the generated WSDL currently looks like this:
<service name="AvailabilityService">
<port name="AvailabilityServicePort" binding="tns:AvailabilityServicePortBinding">
<soap:address location="http://www.example.com/services/AvailabilityService.AvailabilityServicePort/"/>
</port>
</service>
From what I understand, the URL is determined as follows:
The "/services/" portion is specified in the web.xml file. The pattern "/services/*" is specified in the web.xml file to route all requests matching that pattern to the AxisServlet.
The "AvailabiltyService" portion is the service name. It defaults to the value of the "name" parameter of the #WebService annotation with the word "Service" appended to it. This can be overridden by including a "serviceName" parameter on the #WebService annotation. In our case, we have included the "serviceName" parameter on the #WebService annotation with the value "AvailabilityService".
The "AvailabiltyServicePort" portion is the port name. It defaults to the service name with the word "Port" appended to it. This can be overridden by including a "portName" parameter on the #WebService annotation. In our case, we have not included the "portName" parameter on the #WebService annotation.
I realize we would have control over the URL if we used the contract-first approach, where we would write the WSDL ourselves, but we prefer to stay with the code-first approach.
Thank you for your time.
Related
How to expose wsdl behind firewall?
Mule generated WSDL has endpoints to server where it runs but exposing it outside requires change of this endpoint.
Current workaround what we use is to use SOAPUI to export internal service wsdl, edit it in text editor substitute all internal addresses for external analogs, pack this wsdl and send it to the external consumer.
Is there better way to do so? Maybe some parameter to some component which generates the WSDL which defines the server name for endpoints?
UPDATE based on comments:
This is not general question about WSDL. This is Mulesoft related question. Mule generates WSDL automatically. Here is part what I'm interested in:
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address>
location="http://mule.server.internal.local/SayHello/" />
</port>
It is generate because Mule server is at internal box mule.server.internal.local
But when this server is exposed externally it is "hosted" on external site service.mycompany.com, so WSDL should say
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address>
location="http://service.mycompany.com/SayHello/" />
</port>
but Mule does not know about it and so WSDL is invalid.
I need to write a SOAP request to a web service.
It is not working and I am narrowed it down to how I am defining the namespace in the .setRequestHeader "SoapAction" function or the actual SoapRequest string.
The request header requires the parameter [namespace]/[method] of the web service.
I have the web service code and in the .cs file the namespace is PagingService.
The wsdl for the service is:
http://<server>:<port>/PagingService/PagingService.Paging.svc?WSDL.
When I run a console application and access the vbscript, it returns the wsdl when I do a 'GET' and 'Send()' using the httpRequest object. So, I think this is fine.
I have to set the namespace with the method name in the setRequestHeader function:
httpRequest.setRequestHeader "SOAPAction", "PagingService/TestMethod"
Is this the correct way to set the namespace/method in the second parameter of this function?
If this is correct, my SoapRequest string must be wrong.
It requires the urn of the web service. How do I determine that?
To determine the SOAPAction of a web service method:
1. Open the WSDL
2. Find the method that you want to call
3. In my WSDL, the soap action was an attribute of the method.
It looked like this:
<wsdl:operation name="TestMethod">
<soap12:operation soapAction="http://tempuri.org/IPaging/TestMethod" style="document"/>
The namespace is http://tempuri.org/IPaging
The method is: TestMethod
I have a web service deployed on Jetty. I use the SOAP UI to call it via link like http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import and it works.
I have always worked with service which had ?wsdl at the end of url, but now I confused.
Why there is no ?wsdl at the end of url?
A Web Service endpoint usually has an url that looks like this:
http://server:port/services/myservice
It does not have a wsdl parameter. This is the url of the web service itself, the one that will be called by the clients.
Most web service frameworks have a convenient feature in which they map the url of the endpoint with a wsdl url parameter to a webpage that shows the content of the WSDL for that web service. So this url:
http://server:port/services/myservice?wsdl
Is like telling the server: "Show me the wsdl file for this web service endpoint". The content that you see in that webpage is not a wsdl file stored in disk, it is just the content of the wsdl generated by the framework.
This feature is very useful because if we want to create a client for that web service we don't need to go ask for the wsdl file, we can just go and fetch it from that url.
In SoapUI
All this means that in SoapUI you would create a new project and tell him that the wsdl file can be found here: http://server:port/services/myservice?wsdl. If you tell him that the wsdl file is: http://server:port/services/myservice it will throw an error as that is not a wsdl file.
Alternatively you could enter the location of the wsdl file that you have in disk instead of the url and it should create the same ws client.
Then SoapUI will read the wsdl and he will see that the endpoint for the web service is http://server:port/services/myserviceso this is where he will send the requests.
Your web service
In your case, since you are already passing url parameters to the endpoint, you can consider that your webservice will be called at this url:
http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import
And if you want to see the wsdl for that web service, you just add a wsdl parameter to the url. Note that just as any other url query the symbol ? just denotes that the url ends there and next characters are url parameters which are separated by &. In your case you have 3 parameters (workflow, soapAction and now wsdl):
http://ip:port/DefaultRequestListener?workflow=WsdlCPF&soapAction=Import&wsdl
now it returns a text like Company type: blah blah... Region: blah blah...
This is the wsdl content, which of course includes the xml types used in the web service, all normal.
Maybe it looks strange to you because in the wsdl file you have in disk it does not show all these types and instead it imports the xsd files that contain those definitions. The wsdl you see in your browser will never have imports like that, and will always show all the types embedded in the wsdl file.
Scroll down past all those types definitions and you will see the rest of the wsdl.
I hope it helped to make clear that the url with ?wsdl at the end is not the web service and it's just the wsdl content.
I am developing SOAP web service using annotation i.e. #WebService, #WebMethod and XML annotation for request and response entities. The web server generates the WSDL contract which the client uses. I am not able to set any xml restriction on the response elements, say for example i want top set a String element to max length to 50 characters. As I am not writing the WSDL/XSD manually is there a way to define this through annotation so the the server includes in the generated WSDL.
JAX-WS web service uses JAXB for data binding. Unfortunately, the default JAXB reference implementation does not support JAXB facet. So with the default implementation, you cannot use annotation to specify string element maxlength restriction. However, you can check out JAXB-Facets project, which does exactly what you want.
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