问题描述
我正在尝试使用Web服务,但是要使用Web服务,我需要登录。问题是登录服务未返回令牌等。因此,我需要在连接时发送登录请求和其他Web服务请求。就像数据库连接一样。 login(),sendRequest(),logout()。
使用标准的webservicetemplate.marshalSendAndReceive()方法,我会收到 org.springframework.ws.soap.client.soapFaultClientException:需要会话错误消息。 后来,我发现 WebServiceConnection 有用,但无法实现。我不知道是不是出于这个目的。
那么,在春季如何使用webservicetemplate或其他方式实现这一目标?
其他信息
登录服务:https://erpefaturatest.cs.com.tr:8043/efatura/ws/userService?wsdl
Web服务:https://erpefaturatest.cs.com.tr:8043/efatura/ws/connectorService?wsdl
他们在文档中为Java提供了此功能,
public class Login8043 {
public Login8043() {}
Connector8043.ConnectorService port;
public Login8043(String usrname,String pass) {
try {
Connector8043.ConnectorService_Service service = new Connector8043.ConnectorService_Service();
this.port = service.getConnectorServicePort();
this.port = setAuthToPort(port,usrname,pass);
} catch (Exception e) {
e.printstacktrace();
}
}
private static Connector8043.ConnectorService setAuthToPort(Connector8043.ConnectorService port,String username,String password) {
BindingProvider bp = (BindingProvider) port;
Binding binding = bp.getBinding();
List<Handler> handlerChain = new ArrayList<>();
WebServiceSecurityHeaderHandler wsSecurity = new WebServiceSecurityHeaderHandler(username,password);
handlerChain.add(wsSecurity);
binding.setHandlerChain(handlerChain);
return port;
}
}
在提供的代码中,我无法弄清楚“ Connector8043.ConnectorService端口”对象是什么,因此,我无法实现该对象。等待您的帮助。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)