如何在没有 wsdl url 的情况下创建 Axis 客户端?
我想使用本地 wsdl 为 Web 服务创建 Axis 客户端,但不知道 wsdl 的 url。我已经尝试了本教程中的动态调用接口方法 http: //www.ibm.com/developerworks/webservices/library/ws-javaclient/index.html 但出现以下错误:
AxisFault 故障代码: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException 故障子码:故障字符串:无客户端 找到名为“null”的传输! 故障演员:故障节点:故障详细信息: {http://xml.apache.org/axis/}stackTrace:否 发现名为“null”的客户端传输! 在 org.apache.axis.client.AxisClient.invoke(AxisClient.java:170)
我的代码是:
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService","ComposedWebServiceServiceService"));
Call call = service.createCall();
call.setPortTypeName(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService","ComposedWebServiceServicePortType"));
call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped");
call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
call.setReturnType(XMLType.XSD_STRING);
call.setOperationName(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService", "ComposedWebServiceServiceOperation"));
call.addParameter("input1", XMLType.XSD_STRING, ParameterMode.IN);
String[] params = {input};
response = (String)call.invoke(params);
谢谢
I want to create an Axis client for a web service with local wsdl, without knowing the wsdl's url. I've tried the Dynamic Invocation Interface method as in this tutorial http://www.ibm.com/developerworks/webservices/library/ws-javaclient/index.html but I get the following error:
AxisFault faultCode:
{http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode: faultString: No client
transport named 'null' found!
faultActor: faultNode: faultDetail:
{http://xml.apache.org/axis/}stackTrace:No
client transport named 'null' found!
at
org.apache.axis.client.AxisClient.invoke(AxisClient.java:170)
My code is:
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService","ComposedWebServiceServiceService"));
Call call = service.createCall();
call.setPortTypeName(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService","ComposedWebServiceServicePortType"));
call.setProperty(Call.OPERATION_STYLE_PROPERTY, "wrapped");
call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "");
call.setReturnType(XMLType.XSD_STRING);
call.setOperationName(new QName("http://j2ee.netbeans.org/wsdl/CompositionBpelModule/ComposedWebServiceService", "ComposedWebServiceServiceOperation"));
call.addParameter("input1", XMLType.XSD_STRING, ParameterMode.IN);
String[] params = {input};
response = (String)call.invoke(params);
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有和你一样的问题。
经过几个小时的挖掘,似乎我几乎已经解决了这个问题。
发生此异常的原因是缺少设置目标端点地址
这是我的代码
targetEndpoint 参数的值是 port 元素内的 address 元素的 location 属性的值。这是一个示例
您可以通过使用某些 wsdlParser 检索 wsdl 文档来获取此值(我使用 Axis 的 WSDL4J)(请注意,在上面的代码示例中,我已经硬编码了 targetEndpoint 值)
此外,我设置了
OPERATION_STYLE_PROPERTY
rpc 样式和ENCODINGSTYLE_URI_PROPERTY
到 http://schemas.xmlsoap.org/soap /encoding/ (这是默认值)这里是我找到的解决此问题的文档
希望对您有所帮助!抱歉我的英语不好。
I had the same problem as yours.
After digging for hours, it seems like I've almost solved this problem.
This exception occurs because of missing set target endpoint address
Here is my code
The value of targetEndpoint agument is the value of location attribute of address element inside port element. Here is an example
You can get this value by retrieving wsdl document using some wsdlParser (I use Axis's WSDL4J) (Note that in the code example above, I have hardcoded the targetEndpoint value)
Moreover, I set
OPERATION_STYLE_PROPERTY
to rpc style andENCODINGSTYLE_URI_PROPERTY
to http://schemas.xmlsoap.org/soap/encoding/ (this is default value)Here is the document I found to solve this problem
Hope that help you! Sorry for my bad English.