Problem consuming WebService

0

I have a problem when consuming a Web service from a console application, I have added the Reference Service (WS) to the project, but when implementing it within the code when it will execute the method of That Web Service sends me the following error:

  

An unhandled exception of type 'System.ServiceModel.ProtocolException'   occurred in mscorlib.dll

     

Additional information: SOAP header Action was not understood.

I share the AppConfig

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
    </startup>
    <system.serviceModel>
        <bindings>
          <customBinding>
            <binding name="WSAsistenciaSoap">
              <transactionFlow />
              <textMessageEncoding />
              <httpTransport authenticationScheme="Ntlm" />
            </binding>
          </customBinding>
            <basicHttpBinding>
                <binding name="WSAsistenciaSoap">
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="direccion.com"
                binding="customBinding" bindingConfiguration="WSAsistenciaSoap"
                contract="WSOpenHR.WSAsistenciaSoap" name="WSAsistenciaSoap" />
        </client>
    </system.serviceModel>
</configuration>

Where it is thundering when:

Cliente.MetodoWS(dato1,dato2);

Note: Authentication is required and according to the documentation I added <customBinding>

    
asked by M. Gress 06.07.2017 в 01:53
source

1 answer

1

I tell you that I have managed to solve it in the following way:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="WSAsistenciaSoap">
                <security mode="TransportCredentialOnly">
                 <transport clientCredentialType="Windows" />
                </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="direccion.com"
                binding="basicHttpBinding" bindingConfiguration="WSAsistenciaSoap"
                contract="WSOpenHR.WSAsistenciaSoap" name="WSAsistenciaSoap" />
        </client>
    </system.serviceModel>
</configuration>

End using <basicHttpBinding> just add the following in the Binding :

                <security mode="TransportCredentialOnly">
                 <transport clientCredentialType="Windows" />
                </security>
    
answered by 06.07.2017 / 02:39
source