Error in using custom wsdl with axis2 [duplicate] - java

I have followed contract first approach. So I first wrote the wsdl file and then generated the server side code. But when I hit the url for my web service in the browser then I see the auto generated wsdl file; not the one I had kept inside META-INF folder. I have also set useOriginalwsdl=true in my services.xml file. When I try to view the wsdl in browser, it fires error
Unable to generate WSDL 1.1 for this service in description section and
If you wish Axis2 to automatically generate the WSDL 1.1, then please set useOriginalwsdl as false in your services.xml in the reason section of error tag.
Please help me.

useOriginalwsdl=true will work if you have followed the following steps:
put the custom wsdl file inside the META-INF folder.
the service name should be the same in both the custom wsdl as well as in the services.xml
Name the custome wsdl as service.wsdl or (Your ServiceName).wsdl.
Set useOriginalwsdl=true in services.xml file
Note: If useOriginalwsdl=true, Axis2 engine first tries to use any wsdl file named service.wsdl. If not found, then it tries to find named (your service name).wsdl
If not succeeds, then it shows error when u try to access the web service.

Do you have external schema references in your WSDL..? If so, those should be also added to META-INF directory... Please also attach your WSDL..
Since you are using contract first, better you validate your WSDL too.. there are wsdl validating tools available...
Thanks...

Related

Generate Java webservice based on ONVIF wsdl (Top Down Method)

I want to generate server code for a device like Camera. There is a standard protocol for these device called ONVIF which publish some popular WSDL documents. So I must generate an interface and skelton from ONFIV's WSDL documents.
When I use wsdl2java to generate server code from ONVIF wsdl file, it says:
org.apache.axis2.AxisFault: No services found in the WSDL at https://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl with targetnamespace http://www.onvif.org/ver10/device/wsdl
Is there a problem via these WSDL files?
How can generate Server code based on ONVIF WSDL?
I had a same problem in generating java classes from WSDL files in order to create ONVIF web server. After a great deal of investigation I found out there are some errors in WDSL files which I got form https://www.onvif.org
If you want to create java classes properly you need to make some changes on them.
First, in each .wsdl file check the correct path of schemaLocation , it may need to change to : schemaLocation="../../../ver10/schema/onvif.xsd"/>
And also check whether all .wsdl files have service tag like this.
<wsdl:service name="DeviceIOPService">
<wsdl:port name="DeviceIOPort" binding="tmd:DeviceIOBinding">
<soap:address location="http://www.onvif.org/ver10/deviceIO/wsdl"/>
</wsdl:port>
</wsdl:service>
If they don't have , create for them, then run generating command.
If you need further information, inform me.
If you go the link https://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl as you specified for wsdl2java you hit a HTML page you are not getting a WSDL file. See the screenshot below:
The HTML document is actually a valid WSDL i.e. full xml document but it uses a XSLT to transform the XML to HTML for display and this creates a bit of problem for wsdl#java.
If you view the web page source and you remove the XSLT link code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../../ver20/util/onvif-wsdl-viewer.xsl"?>
Becomes:
<?xml version="1.0" encoding="utf-8"?>
Then you can load the WSDL into a WSDL editor and see the operations see screen shot below:
To get this working I would contact the Onvif group and ask them for the WSDL location as the WSDL contains links to XSD files which you will need as well. The current location cannot be used as is.

Where does Jersey store the "application.wadl" file?

I am trying to implement a code in our application which needs to monitor the existing registered resources in Jersey and then make decisions accordingly. I know that Jersey provides an application.wadl file which consists of all its resources at runtime.
My question is there a way to look at this file physically? Does Jersey create this file and store it somewhere in the app directory or is it in memory?
Is it possible to call any Jersey api internally on server to get the same info if this particular file is not available like that?
We are using the application class or runtimeconfig. Jersey auto discovers our resources marked with #Path annotation and we are running on Weblogic and Jersey 2.6.
Any help would be appreciated.
Thanks
No WADL file is created on disk. It is created dynamically upon URL request.
http://[host]:[port]/[context_root]/[resource]/application.wadl
E.g.:
http://localhost:8080/rest-jersey/rest/application.wadl
Also, I've found it very useful to inspect the WADL with the SoapUI tool, which can read your WADL from a URL and parse the resources into a tree format. See pic below.

Tool for downloading/importing WSDL-files for a JAX-WS client

I'm consuming a webservice where the WSDL file contains imports to other wsdl and xsd schemas, e.g:
<import namespace="http://my.api.com/" location="http://other.server.com:8888/context/services/MyService?wsdl=1"/>
which in turn can import other files
<xsd:import namespace="http://my.api.com/" schemaLocation="http://other.server.com:8888/context/services/MyService?xsd=1"/>
The client is generated by cxf with a maven plugin. The main WSDL file is added as a classpath resource. However, at runtime it appears that the client actually needs access to other.server.com:8888 to resolve the WSDL completely. So the question is, does a tool exist for importing and resolving all URLs in a WSDL so that it is not dependent absolute server URLs in other imports in the WSDL, and suitable for including in a client project?
We do not control the WSDL, so we can't change it in the source.
Edit: Looking for a tool that works on Linux
Check the ServiceModel Metadata Utility Tool (Svcutil.exe) from Windows SDK.
svcutil /t:metadata http://service/metadataEndpoint
This tool locates or discovers, one or more related documents that describe a particular XML Web service using the Web Services Description Language (WSDL).
I don't know if I understood your question correctly. I'm having my battles with Jax-ws/SOAP too. :)
If you need to generate the java classes needed to call the webservice you can use Apache CXF. Inside it you have a wsdl2java. You can use it on linux.
Another option in Java SDK, on the bin folder there's the wsimport that you can use it too.
Edit: You can change the final URL at runtime using the Service class created by Apache CXF.
new SomeRandomJaxWSService(new URL(wsdl),new QName(namespace, serviceName))

SOAPFactory creating 'null' value for 'soap' namespace in addressing header tag

From within a J2EE application running in JBoss4.2.3 we are creating a SOAPConnection to invoke a 3rd party's web service. Inside the SOAP Header we have to set the Addressing To and Action tags, with 'mustUnderstand' set to '1'. This 'mustUnderstand' attribute is in the http://www.w3.org/2003/05/soap-envelope namespace. We create this by calling:
SOAPFactory#createName("mustUnderstand", "soap", "http://www.w3.org/2003/05/soap-envelope");
This comes out correctly when we include saaj.jar and saaj-impl.jar in our WEB-INF/lib folder. If I take these out, the namespace comes out null as: xmlns:soap='null' instead of xmlns:soap="http://www.w3.org/2003/05/soap-envelope". Here's the entire bad tag:
<wsa:To xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing' xmlns:soap='null' soap:mustUnderstand='1'>http://domain/web-service.url</wsa:To>.
But if we have those 2 jar files deployed with the app, our own hosted web-services fail when creating Faults (due to a class-cast exception:
javax.xml.soap.SOAPException: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl)
Our J2EE app is a JBossWS web-service that invokes 3rd-party web-services itself. There is an apparent conflict with the jar files.
Any ideas on how to get the http://www.w3.org/2003/05/soap-envelope namespace to be written out in the generated SOAP tag?
I ended up using the API directly to call SOAPHeaderElement#mustUnderstand(true). This looks to have solved this issue since another namespace declaration isn't needed (it uses the soap-env namespace declaration from teh envelope itself.
I still have another issue (JBoss wants to send a chunked HTTP request, which the 3rd party web-service isn't liking, but I haven't looked far enough into that one yet)

SERVICE_OBJECT_SUPPLIER parameter is not specified error

I have developed a webService using axis2 and spring. When I request the
wsdl file from the webservice I get the right wsdl file, but when I want to
use a defined operation of the webservice (using a java client),
I get the following exception:
[CODE]org.apache.axis2.AxisFault: The SERVICE_OBJECT_SUPPLIER parameter is
not specified.
In your services.xml file you need to define following two properties.
org.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier
beanname-that-expose-as-a-WS
Take a look http://axis.apache.org/axis2/java/core/docs/spring.html

Categories

Resources