none
SECU1075: An error was discovered processing the <wsse:Security> header RRS feed

  • Question

  • I try to send the request to ercot and get response(report info),

    1. I cannot add the web service fron VS2010, like "Add Service Reference".

    2. Use svcutil.exe /language:cs /s /serializer:XmlSerializer *.wsdl  *.xsd  to create 2 files, one is  WS-BaseNotification.cs, the out is output.config file.

    3. I conbind the config with app.config in my console project. the part likes below:

           <system.serviceModel>
                 <diagnostics>
                      <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
                      <endToEndTracing messageFlowTracing="true" />
                 </diagnostics>

                 <bindings>
                      <basicHttpBinding>
                          <binding name="HttpEndPointBinding" 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="Transport">
                                      <transport clientCredentialType="Certificate">
                                         </transport>
                                      <message clientCredentialType="UserName" algorithmSuite="Default" ></message>
                                 </security>
                         </binding>
                         <binding name="NodalSOAP" 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="Transport">
                                          <transport clientCredentialType="Certificate"  />
                                          <message clientCredentialType="UserName" algorithmSuite="Default" />
                                </security>
                           </binding>
          </basicHttpBinding>
        </bindings>
        <client>
          <endpoint address="https://misapi.ercot.com/2007-08/Nodal/eEDS/EWS/"
            binding="basicHttpBinding" bindingConfiguration="HttpEndPointBinding"
            contract="Operations" name="HttpEndPointBinding">
          </endpoint>
          <endpoint address="http://www.ercot.com/Nodal/" binding="basicHttpBinding"
            bindingConfiguration="NodalSOAP" contract="Operations1" name="NodalSOAP" />
        </client>
      </system.serviceModel>

    there are 2 bindings and 2 endpoints.

    my code like:

          

    EndpointAddress ea = new EndpointAddress("https://misapi.ercot.com/2007-08/Nodal/eEDS/EWS/");
              
                OperationsClient client = new OperationsClient("HttpEndPointBinding", ea);

                System.Security.Cryptography.X509Certificates.X509Certificate2 ercotcert = new System.Security.Cryptography.X509Certificates.X509Certificate2("C:\\ESettlement\\ESettlement\\Albert qse 12192014.cer");
                client.ClientCredentials.ClientCertificate.Certificate = ercotcert;
                client.Open(); 
               
                DateTime dt = new DateTime(2014, 01, 01);
                RequestMessage RM = new RequestMessage();
                RequestType rt = new RequestType();
                HeaderType ht = new HeaderType();

                rt.StartTime = new DateTime(2014, 01, 01);
                rt.StartTimeSpecified = true;
                rt.EndTime = new DateTime(2014, 01, 01);
                rt.EndTimeSpecified = true;
                rt.Option = "11113";//Real Time Market Consolidated Operating Day Extract
                rt.OperatingDate = DateTime.Now;
                rt.MarketType = RequestTypeMarketType.DAM;

                ht.UserID = "API_xxxxxxxxx";
                ht.Verb = HeaderTypeVerb.get;
                ht.Noun = "Reports";
                AttributedDateTime adt = new AttributedDateTime();
                EncodedString es = new EncodedString();
                es.Value = "98765498765";
                es.EncodingType = "Base64Binary";

                adt.Value = dt.ToShortDateString();
                ReplayDetectionType rdt = new ReplayDetectionType();
                rdt.Created = adt;
                rdt.Nonce = es;
                ht.ReplayDetection = rdt;


                ht.Revision = "001";
                ht.Source = "QSAMP";
                ht.MessageID = "151451";
                RM.Header = ht;
                RM.Request = rt; 

    ResponseMessage responsemessage = client.MarketInfo(RM);/////I got the error message like title.

    I check the RM(request message), it likes:

    <RequestMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <Header xmlns="http://www.ercot.com/schema/2007-06/nodal/ews/message">
        <Verb>get</Verb>
        <Noun>Reports</Noun>
        <ReplayDetection>
          <Nonce>98765498765</Nonce>
          <Created>12/1/2011</Created>
        </ReplayDetection>
        <Revision>001</Revision>
        <Source>QSAMP</Source>
        <UserID>USER1</UserID>
        <MessageID>151451</MessageID>
      </Header>
      <Request xmlns="http://www.ercot.com/schema/2007-06/nodal/ews/message">
        <StartTime>2011-12-01T00:00:00</StartTime>
        <EndTime>2011-12-01T00:00:00</EndTime>
        <Option>12300</Option>
      </Request>
    </RequestMessage>

    my incoming request should look like below on server:

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope
       xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <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:BinarySecurityToken
                   EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"
                   ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"
                   wsu:Id="CertId-11783550" xmlns:wsu="blahblahblahHw=</wsse:BinarySecurityToken">http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">blahblahblahHw=</wsse:BinarySecurityToken>
               <ds:Signature Id="Signature-1323057605" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                   <ds:SignedInfo>
                       <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                       <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
                       <ds:Reference URI="#id-899368668">
                           <ds:Transforms>
                               <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                           </ds:Transforms>
                           <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                           <ds:DigestValue>Y/R5t6tGTHv3PsKozXaqH5mMgww=</ds:DigestValue>
                       </ds:Reference>
                   </ds:SignedInfo>
                   <ds:SignatureValue>
    blahblahTVw=
    </ds:SignatureValue>
                   <ds:KeyInfo Id="KeyId-2035159355">
                       <wsse:SecurityTokenReference
                           wsu:Id="STRId-162291475" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                           <wsse:Reference URI="#CertId-11783550" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
                       </wsse:SecurityTokenReference>
                   </ds:KeyInfo>
               </ds:Signature>
           </wsse:Security>
       </soapenv:Header>
       <soapenv:Body wsu:Id="id-899368668" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
           <ns1:RequestMessage xmlns:ns1="http://www.ercot.com/schema/2007-06/nodal/ews/message">
               <ns1:Header>
                   <ns1:Verb>get</ns1:Verb>
                   <ns1:Noun>Reports</ns1:Noun>
                   <ns1:ReplayDetection>
                       <ns1:Nonce>TmBLahBlah</ns1:Nonce>
                       <ns1:Created>2014-01-23T13:05:11-06:00</ns1:Created>
                   </ns1:ReplayDetection>
                   <ns1:Revision>1.0</ns1:Revision>
                   <ns1:Source>QXXX</ns1:Source>
                   <ns1:UserID>API_abc1234567</ns1:UserID>
               </ns1:Header>
               <ews:Request xmlns:ews="http://www.ercot.com/schema/2007-06/nodal/ews/message">
                   <ews:StartTime>2014-01-16T00:00:00-06:00</ews:StartTime>
                   <ews:EndTime>2014-01-26T00:00:00-06:00</ews:EndTime>
                   <ews:Option>12345</ews:Option>
               </ews:Request>
           </ns1:RequestMessage>
       </soapenv:Body>
    </soapenv:Envelope>

    I am new for wcf web service. I appreciate if any help.

    Thanks

    Friday, January 24, 2014 9:46 PM

Answers

  • Hi,

    I see that you use the username authentication, maybe you can add the headers manually like this:

    using (new OperationContextScope(client.InnerChannel))
    {
        OperationContext.Current.OutgoingMessageHeaders.Add(
            new SecurityHeader("UsernameToken-49", "12345/userID", "password123"));
        client.invokeIdentityService(new IdentityProofingRequest());
    }

    Here, SecurityHeader is a custom implemented class, which needs a few other classes since I chose to use attributes to configure the XML serialization:

    public class SecurityHeader : MessageHeader
    {
        private readonly UsernameToken _usernameToken;
    
        public SecurityHeader(string id, string username, string password)
        {
            _usernameToken = new UsernameToken(id, username, password);
        }
    
        public override string Name
        {
            get { return "Security"; }
        }
    
        public override string Namespace
        {
            get { return "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; }
        }
    
        protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(UsernameToken));
            serializer.Serialize(writer, _usernameToken);
        }
    }
    
    
    [XmlRoot(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")]
    public class UsernameToken
    {
        public UsernameToken()
        {
        }
    
        public UsernameToken(string id, string username, string password)
        {
            Id = id;
            Username = username;
            Password = new Password() {Value = password};
        }
    
        [XmlAttribute(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd")]
        public string Id { get; set; }
    
        [XmlElement]
        public string Username { get; set; }
    
        [XmlElement]
        public Password Password { get; set; }
    }
    
    public class Password
    {
        public Password()
        {
            Type = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
        }
    
        [XmlAttribute]
        public string Type { get; set; }
    
        [XmlText]
        public string Value { get; set; }
    }

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 27, 2014 8:39 AM
    Moderator