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 with targetnamespace 

Is there a problem via these WSDL files?
How can generate Server code based on ONVIF WSDL?

2 Answers

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

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=""/> </wsdl:port> </wsdl:service> 

If they don't have , create for them, then run generating command. If you need further information, inform me.

1

If you go the link as you specified for wsdl2java you hit a HTML page you are not getting a WSDL file. See the screenshot below:

enter image description here

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:

enter image description here

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.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like