[英]JAX-RPC, Spring web services, and UnsupportedOperationCallException
I have a JAX-RPC web service that I am attempting to consume using Spring. 我有一个使用Spring尝试使用的JAX-RPC Web服务。 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.
这是我第一次使用Spring来使用Web服务,所以现在我只是想使其与JAX-RPC Web服务集成作为测试。
The web service has several dozen operations in it, but for right now I only care about one. 该Web服务中包含数十种操作,但是目前我只关心其中一项。 Here are the interfaces I've created on the Spring/client side:
这是我在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);
}
And here is my applicationContext.xml: 这是我的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: 使用
JaxRpcPortProxyFactoryBean
此配置,调用服务将返回以下异常:
org.springframework.remoting.RemoteProxyFailureException: Invalid JAX-RPC call configuration;
org.springframework.remoting.RemoteProxyFailureException:无效的JAX-RPC调用配置; nested exception is operation style: "rpc" not supported
嵌套异常是操作样式:不支持“ rpc”
I've never fully understood the difference between RPC and document-style web services; 我从来没有完全理解RPC和文档样式的Web服务之间的区别。 however, I believe this web service is using RPC-style - so this exception confuses me.
但是,我相信此Web服务使用的是RPC样式-因此此异常使我感到困惑。
Second, I'm confused on which properties I should be setting with JaxRpcPortProxyFactoryBean
: 其次,我对应该使用
JaxRpcPortProxyFactoryBean
设置哪些属性感到困惑:
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. wsdlDocumentUrl
属性,由于该Web服务位于HTTP基本身份验证后面,我最终会收到HTTP 401错误,并且在获取WSDL时Spring似乎没有使用username / password属性。 PortInterface
property (with a value of CompanyWebServiceInterfacePort
), then I get a different Exception stating: PortInterface
属性(值为CompanyWebServiceInterfacePort
),那么我将得到另一个异常说明:
Failed to initialize service for JAX-RPC port [{ http://www.company.com/wdsl }CompanyWebServiceInterfacePort];
无法初始化JAX-RPC端口[{ http://www.company.com/wdsl } CompanyWebServiceInterfacePort]的服务; nested exception is WSDL data missing, this operation is not available
嵌套异常是缺少WSDL数据,此操作不可用
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! 换句话说,这是在告诉我缺少WSDL-我无法设置WSDL,因为Spring不会使用用户名/密码从服务器中获取用户名/密码!
I'm not sure if any of this makes any sense, but in essence what I'm unsure of is: 我不确定这是否有意义,但是本质上我不确定的是:
wsdlDocumentUrl
property? wsdlDocumentUrl
属性? If so, is there any way I can tell Spring which WSDL and get around the authentication problem? 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
. 我最终通过在本地保存WSDL文件的副本解决了此问题,并且由于JaxRpcPortProxyFactoryBean希望
wsdlDocumentUrl
属性具有java.net.URL
,因此必须使用file:///c:/.../blah.wsdl
这样的路径进行设置。 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. 这并不是真正想要的,我讨厌必须将
file:///
URI放入可能部署在服务器上的Spring上下文文件中,尤其是在不同的平台上-此类的行为方式似乎很奇怪。
I'm guessing most people aren't using Spring aren't using JAX-RPC anyway. 我猜想大多数人不使用Spring也不使用JAX-RPC。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.