From a C# program I am trying to call a WebService written in Java. If I use SoapUi to call the WS I can see in fiddler that the call looks like this:
<soap:Envelope xmlns:ser="http://service.webservice.com" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-8684DEB94ABXXXXXXXXXX362973">
<wsse:Username>MyUserName</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">MyPassword</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">fjwe5h78k7vgheedRv21g==</wsse:Nonce>
<wsu:Created>2016-11-17T11:53:56.297Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<ser:getTrades>
<ser:filter>
<ser:fromValueDate>2015-03-23</ser:fromValueDate>
<ser:toValueDate>2015-03-23</ser:toValueDate>
</ser:filter>
</ser:getTrades>
</soap:Body>
</soap:Envelope>
The Problem is that VisualStudio creates the classes without the header options
// CODEGEN: The optional WSDL extension element 'Policy' from namespace
'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
So how do I add the Soap header with the username and pw to make the call in C# ?
I also been looking in using WCF, and from the wsdl (here in part)
.
.
.
<wsdl:binding name="TradeRetrieverServiceSOAP12Binding" type="ns0:TradeRetrieverServicePortType">
<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" Id="UsernameTokenOverHTTPS">
<wsp:ExactlyOne>
<wsp:All>
<sp:TransportBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken RequireClientCertificate="false"/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Lax/>
</wsp:Policy>
</sp:Layout>
</wsp:Policy>
</sp:TransportBinding>
<sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"/>
</wsp:Policy>
</sp:SignedSupportingTokens>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
.
.
it creates this bindings:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="TradeRetrieverServiceSOAP12Binding">
<security defaultAlgorithmSuite="Default" authenticationMode="UserNameOverTransport"
requireDerivedKeys="true" securityHeaderLayout="Lax" includeTimestamp="false">
<localClientSettings detectReplays="false" />
<localServiceSettings detectReplays="false" />
</security>
<textMessageEncoding messageVersion="Soap12" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://Myservices/TradeRetrieverService"
binding="customBinding" bindingConfiguration="TradeRetrieverServiceSOAP12Binding"
contract="ServiceReference1.TradeRetrieverServicePortType" name="TradeRetrieverServiceSOAP12port_http" />
</client>
</system.serviceModel>
But this gives me this error:
The provided URI scheme 'http' is invalid; expected 'https'.
Parameter name: via
The url is a http and not https
So I am stock here. Any ideas?
EDIT
I now get data, well in fiddler, in code I get this error:
The header 'Security' from the namespace 'http://docs.oasis- open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
was not understood by the recipient of this message, causing the message to not be processed.
This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process.
Please ensure that the configuration of the client's binding is consistent with the service's binding.