如何在没有 wsdl url 的情况下创建 Axis 客户端?

发布于 2024-11-08 19:00:19 字数 1570 浏览 0 评论 0原文

我想使用本地 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等风来 2024-11-15 19:00:19

我有和你一样的问题。
经过几个小时的挖掘,似乎我几乎已经解决了这个问题。
发生此异常的原因是缺少设置目标端点地址
这是我的代码

        Call call = service.createCall();
        call.setPortTypeName(portQName);
        call.setOperationName(new QName(namespace, operation));
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/"); 
        call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
        call.addParameter("in0", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        call.addParameter("in1", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        call.setReturnType(serviceQName);
        String targetEndpoint = "http://113.160.19.218:8312/axis/services/WeatherForecastTest1";
        call.setTargetEndpointAddress(targetEndpoint);
        String result = (String) call.invoke(params);
        out.println(result);

targetEndpoint 参数的值是 port 元素内的 address 元素的 location 属性的值。这是一个示例

<service name="WeatherForecastTest1Service">
    <port binding="impl:WeatherForecastTest1SoapBinding" name="WeatherForecastTest1">
      <wsdlsoap:address location="http://113.160.19.218:8312/axis/services/WeatherForecastTest1"/>
   </port>
  </service>

您可以通过使用某些 wsdlParser 检索 wsdl 文档来获取此值(我使用 Axis 的 WSDL4J)(请注意,在上面的代码示例中,我已经硬编码了 targetEndpoint 值)

此外,我设置了 OPERATION_STYLE_PROPERTY rpc 样式和 ENCODINGSTYLE_URI_PROPERTYhttp://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

        Call call = service.createCall();
        call.setPortTypeName(portQName);
        call.setOperationName(new QName(namespace, operation));
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/"); 
        call.setProperty(Call.OPERATION_STYLE_PROPERTY, "rpc");
        call.addParameter("in0", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        call.addParameter("in1", org.apache.axis.Constants.XSD_STRING ,ParameterMode.IN);
        call.setReturnType(serviceQName);
        String targetEndpoint = "http://113.160.19.218:8312/axis/services/WeatherForecastTest1";
        call.setTargetEndpointAddress(targetEndpoint);
        String result = (String) call.invoke(params);
        out.println(result);

The value of targetEndpoint agument is the value of location attribute of address element inside port element. Here is an example

<service name="WeatherForecastTest1Service">
    <port binding="impl:WeatherForecastTest1SoapBinding" name="WeatherForecastTest1">
      <wsdlsoap:address location="http://113.160.19.218:8312/axis/services/WeatherForecastTest1"/>
   </port>
  </service>

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 and ENCODINGSTYLE_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文