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

瘦欲@ 提交于 2019-12-23 11:59:36

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/46662145/generate-java-webservice-based-on-onvif-wsdl-top-down-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!