Xfire调用webservice出错
程序员文章站
2022-03-02 08:57:17
...
今天使用Xfire调用ws出现了报错。。
org.codehaus.xfire.fault.XFireFault: There must be a method name element.
调用代码如下:
根据wsdl创建的相应接口如下:
最后发现是url的问题,如果是通过 ObjectServiceFactory、XFireProxyFactory方式来动态生成的,需要把访问路径的WSDL去掉,类似于
http://www.12580sky.com/xfire/demoCommonService?WSDL
改成
http://www.12580sky.com/xfire/demoCommonService
org.codehaus.xfire.fault.XFireFault: There must be a method name element.
调用代码如下:
Service service = new ObjectServiceFactory().create(MyTest.class); XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire()); String helloURL = "http://220.249.111.121//services/AAS"; String cmd = ""; try { MyTest my = (MyTest)factory.create(service, helloURL); System.out.println(my.doDelete(cmd)); } catch (MalformedURLException e) { e.printStackTrace(); }
根据wsdl创建的相应接口如下:
interface MyTest { String doDelete(String param); String doDTest(String param); String doConfig(String param); String doCheck(String param); }
最后发现是url的问题,如果是通过 ObjectServiceFactory、XFireProxyFactory方式来动态生成的,需要把访问路径的WSDL去掉,类似于
http://www.12580sky.com/xfire/demoCommonService?WSDL
改成
http://www.12580sky.com/xfire/demoCommonService
上一篇: ImageView倒影效果
下一篇: docker笔记