简体   繁体   中英

Security header in WSDL C#

I have to make a client for a WSDL. But I keep getting a "No Security header in message but required by policy."

Here is my code

            USImportoerService service = new USImportoerService();
            X509Certificate2 cert = new X509Certificate2(certPath, PASSWORD, X509KeyStorageFlags.MachineKeySet);

            service.ClientCertificates.Add(cert);

            var result = ser.getUSKoeretoej();

And heres the App.config

<configuration>
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="USImportoerService_Port">
              <security authenticationMode="CertificateOverTransport" securityHeaderLayout="LaxTimestampLast" includeTimestamp="true" 
            enableUnsecuredResponse="true">
              </security>
                <textMessageEncoding messageVersion="Soap11" />
                <httpsTransport />
            </binding>
        </customBinding>
    </bindings>
  <client>
        <endpoint address="HTTPS TO WSDL"
            binding="customBinding" bindingConfiguration="USImportoerService_Port"
            contract="ServiceReferenceUSImportoer.USImportoerServiceType"
            name="Port1" />
    </client>
</system.serviceModel>

Hope someone can help

Use HttpClient to call SOAP Service

   USImportoerService service = new USImportoerService();
   X509Certificate2 cert = new X509Certificate2(certPath, PASSWORD, X509KeyStorageFlags.MachineKeySet);
    HttpClientHandler handler = new HttpClientHandler();
    handler.ClientCertificates.Add(cert);
    HttpClient client = new HttpClient(handler);
    // Call service using httpClient
    //var result = ser.getUSKoeretoej();

How to call SOAP Service using httpClient Client to send SOAP request and receive response

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM