JAX-RPC、Spring Web 服务和 UnsupportedOperationCallException

发布于 2024-07-08 05:40:14 字数 2418 浏览 8 评论 0原文

我有一个 JAX-RPC Web 服务,我尝试使用 Spring 来使用它。 这是我第一次使用 Spring 来使用 Web 服务,所以现在我只是尝试将其与 JAX-RPC Web 服务集成作为测试。

Web 服务中有几十个操作,但目前我只关心一个。 以下是我在 Spring/客户端创建的接口:

public interface WSClient {
    public boolean userExists(int userid);
}

public interface WSService {
    //this method matches the method signature of the Web Service
    public com.company.data.User getUser(int userid);
}

这是我的 applicationContext.xml:

<bean id="WSClient" class="com.company.ws.test.WSClientImpl">
    <property name="service" ref="myWebService"></property>
</bean>

<bean id="myWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    <property name="serviceInterface" value="com.company.ws.test.WSService"/>
    <property name="endpointAddress" value="http://1.2.3.4/web-service/data"/>
    <property name="namespaceUri" value="http://www.company.com/wdsl"/>
    <property name="serviceName" value="CompanyWebService"/>
    <property name="username" value="username"/>
    <property name="password" value="password"/>
    <property name="maintainSession" value="true"/>
</bean>

使用 JaxRpcPortProxyFactoryBean 的此配置,调用服务会返回以下异常:

org.springframework.remoting.RemoteProxyFailureException:无效的 JAX-RPC 调用配置; 嵌套异常是操作方式:不支持“rpc”

我从来没有完全理解RPC和文档式Web服务之间的区别; 然而,我相信这个 Web 服务正在使用 RPC 风格 - 所以这个异常让我感到困惑。

其次,我对应该使用 JaxRpcPortProxyFactoryBean 设置哪些属性感到困惑:

  1. 如果我设置 wsdlDocumentUrl 属性,我最终会收到 HTTP 401 错误,因为此 Web 服务位于在 HTTP 基本身份验证后面,Spring 在获取 WSDL 时似乎不使用用户名/密码属性。
  2. 如果我指定 PortInterface 属性(值为 CompanyWebServiceInterfacePort),则会收到不同的异常,说明: <块引用>

    无法初始化 JAX-RPC 端口服务 [{http://www.company.com/wdsl< /a>}CompanyWebServiceInterfacePort]; 嵌套异常是 WSDL 数据丢失,此操作不可用

换句话说,它告诉我 WSDL 丢失 - 我无法设置它,因为 Spring 不会使用用户名/密码从服务器获取它!

我不确定这些是否有意义,但本质上我不确定的是:

  1. 对于 JAX-RPC 服务,我是否需要设置 PortInterface 属性? 这是我应该走的路吗?
  2. 同样,Spring 是否需要我设置 wsdlDocumentUrl 属性? 如果是这样,有什么方法可以告诉 Spring 哪个 WSDL 并解决身份验证问题吗?

I have a JAX-RPC web service that I am attempting to consume using Spring. This is my first time using Spring to consume a web service, so right now I'm just trying to get it to integrate with the JAX-RPC web service as a test.

The web service has several dozen operations in it, but for right now I only care about one. Here are the interfaces I've created on the Spring/client side:

public interface WSClient {
    public boolean userExists(int userid);
}

public interface WSService {
    //this method matches the method signature of the Web Service
    public com.company.data.User getUser(int userid);
}

And here is my applicationContext.xml:

<bean id="WSClient" class="com.company.ws.test.WSClientImpl">
    <property name="service" ref="myWebService"></property>
</bean>

<bean id="myWebService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
    <property name="serviceInterface" value="com.company.ws.test.WSService"/>
    <property name="endpointAddress" value="http://1.2.3.4/web-service/data"/>
    <property name="namespaceUri" value="http://www.company.com/wdsl"/>
    <property name="serviceName" value="CompanyWebService"/>
    <property name="username" value="username"/>
    <property name="password" value="password"/>
    <property name="maintainSession" value="true"/>
</bean>

Using this configuration of JaxRpcPortProxyFactoryBean, invoking the Service returns the following exception:

org.springframework.remoting.RemoteProxyFailureException: Invalid JAX-RPC call configuration; nested exception is operation style: "rpc" not supported

I've never fully understood the difference between RPC and document-style web services; however, I believe this web service is using RPC-style - so this exception confuses me.

Second, I'm confused on which properties I should be setting with JaxRpcPortProxyFactoryBean:

  1. If I set the wsdlDocumentUrl property, I end up getting a HTTP 401 error as this web service sits behind HTTP Basic Authentication, and it seems Spring does not use the username/password properties when fetching the WSDL.
  2. If I specify a PortInterface property (with a value of CompanyWebServiceInterfacePort), then I get a different Exception stating:

    Failed to initialize service for JAX-RPC port [{http://www.company.com/wdsl}CompanyWebServiceInterfacePort]; nested exception is WSDL data missing, this operation is not available

In other words, it's telling me that the WSDL is missing - which I can't set since Spring won't use the username/password to fetch it from the server!

I'm not sure if any of this makes any sense, but in essence what I'm unsure of is:

  1. For a JAX-RPC service, do I need to set the PortInterface property? Is this the path I should be going down?
  2. Similiarly, does Spring need me to set the wsdlDocumentUrl property? If so, is there any way I can tell Spring which WSDL and get around the authentication problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

汐鸠 2024-07-15 05:40:14

我最终通过在本地保存 WSDL 文件的副本解决了这个问题,并且由于 JaxRpcPortProxyFactoryBean 需要 wsdlDocumentUrl 属性的 java.net.URL ,因此必须使用类似 file:///c:/.../blah.wsdl 的路径。

这并不是那么理想,我不想将 file:/// URI 放入可能部署在服务器上的 Spring 上下文文件中,尤其是在不同的平台上 - 似乎奇怪的是这个类的行为方式如此。

我猜大多数人不使用 Spring 也不使用 JAX-RPC。

I eventually solved this by saving a copy of the WSDL file locally, and, since JaxRpcPortProxyFactoryBean expects a java.net.URL for the wsdlDocumentUrl property, had to set it with a path like file:///c:/.../blah.wsdl.

This isn't really all that desireable, I would hate to have to put a file:/// URI in a Spring context file that might be deployed on a server, especially on a different platform - seems odd that this class behaves this way.

I'm guessing most people aren't using Spring aren't using JAX-RPC anyway.

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