总而言之,我正在尝试使用C#来使用javaspring wsse Web服务。这就是我需要发送的webservice头像......
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-27777511"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>username</wsse:Username>
<wsse:Password
type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
我尝试过使用wse3.0自定义策略断言而没有运气。我正在使用VS 2008.我正在使用一个基本的控制台应用程序,在使用这个webservice时应该没有任何问题。这是我的app.config,它在添加服务引用时自动更新
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="wsSoap11" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
我调用该服务的客户端代码是:
SecurityBindingElement securityElement = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
securityElement.IncludeTimestamp = false;
TextMessageEncodingBindingElement encodingElement = new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8);
HttpTransportBindingElement transportElement = new HttpTransportBindingElement();
CustomBinding customBinding = new CustomBinding(securityElement, encodingElement, transportElement);
EndpointAddress endpoint = new EndpointAddress("http://11.11.22.222:8080/OpenClinica-ws/ws/studyEventDefinition/v1/studyEventDefinitionWsdl.wsdl");
ServiceReference1.wsClient cl = new wsClient(customBinding, endpoint);
cl.ClientCredentials.UserName.UserName = "x";
cl.ClientCredentials.UserName.Password = "y";
studyRefType sr = new studyRefType();
sr.identifier = "S_12345";
listAllRequest la = new listAllRequest();
la.studyEventDefinitionListAll = new studyEventDefinitionListAllType();
la.studyEventDefinitionListAll.studyRef = sr;
var response = cl.listAll(la);
我从这里获得了自定义绑定示例Creating Headers (wsse) Section of WCF Client Programatically in C#。端点是http,我无法发送时间戳,因此使用它。
我收到错误:
'CustomBinding'。'http://tempuri.org/'绑定 'ws'。'http://openclinica.org/ws/studyEventDefinition/v1'合同是 配置了需要传输级别的身份验证模式 诚信和保密。但是运输无法提供 诚信和保密。
对不起,我很抱歉。这是我第一次尝试使用任何java spring webservice。如果需要,我可以提供更多信息。我宁愿在我的.cs文件中以编程方式执行此操作。非常感谢您的任何想法/帮助。