Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SoapWS.myRequest req = new SoapWS.myRequest();
- // setup the request fields
- CustomBinding binding = new CustomBinding();
- binding.Namespace = "urn:<the name space>";
- binding.Name = "<name of binding>";
- TransportSecurityBindingElement securityElement = new TransportSecurityBindingElement();
- securityElement.IncludeTimestamp = true;
- X509Certificate cert = new X509Certificate(<from loaded bytes>);
- binding.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, System.Text.Encoding.UTF8));
- binding.Elements.Add(securityElement);
- binding.Elements.Add(new HttpsTransportBindingElement());
- SoapWS.myRequestClient client = new SoapWS.myRequestClient(
- binding,
- addr);
- //client.ClientCredentials.UserName.UserName = "admin";
- //client.ClientCredentials.UserName.Password = "admin";
- using (new OperationContextScope(client.InnerChannel))
- {
- // Add a SOAP Header to an outgoing request
- MessageHeader aMessageHeader = MessageHeader.CreateHeader("Security", binding.Namespace, cert);
- OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);
- }
- client.myRequestCompleted += Client_completed;
- client.myRequestSessionAsync(req);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement