我有一个JAX-RPC Web服务,我试图使用Spring进行使用。这是我第一次使用Spring来使用Web服务,所以现在我只是试图将它与JAX-RPC Web服务集成为一个测试。JAX-RPC,Spring Web服务和UnsupportedOperationCallException
该Web服务有几十个操作,但现在我只关心一个。下面是我在春/客户端创建的接口:
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
进行设置:
- 如果我设置了
wsdlDocumentUrl
财产,我最终得到一个HTTP 401错误,因为这Web服务背后坐镇HTTP基本验证,并且Spring似乎在获取WSDL时不使用用户名/密码属性。 - 如果我指定
PortInterface
属性(具有CompanyWebServiceInterfacePort
的值),然后我得到一个不同的异常,指出:无法为JAX-RPC端口初始化服务[{http://www.company.com/wdsl} CompanyWebServiceInterfacePort];嵌套的例外是WSDL数据丢失,此操作不可
换句话说,它告诉我,WSDL丢失 - 这我不能,因为弹簧组将不使用用户名/密码从服务器获取它!
我不知道是否有任何这使得任何意义,但在本质上有什么我不能确定的是:
- 对于JAX-RPC服务,做我需要设置portInterface进行财产?这是我应该走下去的道路吗?
- 同样,春天是否需要我设置
wsdlDocumentUrl
属性?如果是这样,有什么办法可以告诉Spring哪些WSDL和解决认证问题?