如何解决Java 客户端中带有 wsHttpBinding Axis2 的 WCF 服务的安全令牌问题
我必须在 Java 客户端中使用 WCF 服务。我已经使用 Axis2 库生成了代理代码。我已成功配置代理类,但在调用 WCF 服务方法时出现问题。
以下是我的java客户端中的代码。
ServiceXMLStub stub = new ServiceXMLStub("https://qa1-myservice.com/integration/ServiceXML.svc");
GetMetadata meta = new GetMetadata();
meta.setStateCode("WA");
meta.setUserName("tpstester1");
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE,HTTPConstants.MEDIA_TYPE_APPLICATION_ECHO_XML);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.DISABLE_SOAP_ACTION,Boolean.TRUE);
stub._getServiceClient().engageModule("addressing");
stub._getServiceClient().getOptions().setUserName("myuser");
stub._getServiceClient().getOptions().setPassword("myp@ssw0rd");
GetMetadataResponse response = stub.getMetadata(meta);
以下是我从该客户端调用此服务时遇到的问题。
org.apache.axis2.AxisFault: The message could not be processed. This is most likely because the
action 'http://Integration.ContractsXML/IServiceXML/GetMetadata' is incorrect or because the message
contains an invalid or expired security context token or because there is a mismatch between
bindings.
The security context token would be invalid if the service aborted the channel due to inactivity. To
prevent the service from aborting idle sessions prematurely increase the Receive timeout on the
service endpoint's binding.
我在 .Net 客户端测试了这段代码,它在那里工作正常
ServiceReference1.ServiceXMLClient serviceClient = new ServiceReference1.ServiceXMLClient();
serviceClient.ClientCredentials.UserName.UserName = "myuser";
serviceClient.ClientCredentials.UserName.Password = "myp@ssw0rd";
var result = serviceClient.GetMetadata("tpstester1","SA");
我在这里遗漏了什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。