连接到 RPC SOAP 服务的确切 url 是什么



我有MyService(AXIS 1.4服务)可通过以下网址获得:

curl http://localhost:9999/prefix/services/MyService?wsdl

把它放到浏览器查询行,我有XML WSDL。

问题是:我应该在代码中使用哪个 URL 连接到 MyService 以在那里调用特定方法?

这是我现在的连接代码:

InterfacePortType_Stub stub 
                              = (InterfacePortType_Stub) myService.getPort();
stub._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, 
    "http://localhost:9999/prefix/services/MyService");
this.port = stub;
final MyResponse myResponse = port.myMethod(myRequest);

所以,我使用**http://localhost:9999/prefix/services/MyService**字符串进行连接。但它不起作用 - myResponse.status = 失败。

在我生成的文件的顶部,我有一个这样的标题:

// This class was generated by the JAXRPC SI, do not edit.
// Contents subject to change without notice.
// JAX-RPC Standard Implementation (1.1.2_01, build R40)
// Generated source version: 1.1.2

要调用安讯士服务,首先需要正确初始化它。您的代码应如下所示:

//Your service interface.
InterfacePortTypeService proxy = null;
//Create a locator instance from Axis generated class.
InterfacePortTypeLocator locator = new InterfacePortTypeLocator();
//Get your service from locator.
proxy = locator.getInterfacePortType(new URL("http://localhost:9999/prefix/services/MyService"));
//Call your methods;
proxy.someMethod();

我不知道您生成的所有类的名称,因此这只是如何初始化Axis服务的示例。

最新更新