So in summary I’m trying to consume a javaspring wsse web service using C#. This is what the webservice header I need to send looks like..
<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>
I have tried using wse3.0 custom policy assertions with no luck. I’m using VS 2008. I’m using a basic console application which should pose no problems when consuming this webservice.This is my app.config which is automatically updated when adding the service reference
<?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>
My client code to call the service is:
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);
I got the custom binding example from here Creating Headers (wsse) Section of WCF Client Programatically in C#. The endpoint is http and I cannot send timestamp hence is used it.
I get an error:
The 'CustomBinding'.'http://tempuri.org/' binding for the 'ws'.'http://openclinica.org/ws/studyEventDefinition/v1' contract is configured with an authentication mode that requires transport level integrity and confidentiality. However the transport cannot provide integrity and confidentiality.
I’m sorry if I’m blunt in anyway. This is my first attempt trying to consume any java spring webservice. I can provide more information if needed. I would prefer to do it programatically in my .cs file. Thank you so much for any thoughts/help.