HTTP error 400 calling a webservice method

0

I am consuming a webservice in my .net application and calling a method on the webservice is giving me the following error:

System.ServiceModel.ProtocolException
  HResult=0x80131501
  Message=The remote server returned an unexpected response: (400) Bad Request.
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

The code to call the webservice is as follows:

    testws.B2BServiceClient b2BServiceClient = new testws.B2BServiceClient();
    testws.CancelRequest cancelRequest = new testws.CancelRequest();

    cancelRequest = new testws.CancelRequest
    {
        Service_ID = "test_service_id",
        Provider_Ref = "test_provider_ref"
    };

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;

    b2BServiceClient.ClientCredentials.UserName.UserName = "myusername";
    b2BServiceClient.ClientCredentials.UserName.Password = "mypasssword";
    testws.Response response = b2BServiceClient.CancelService(cancelRequest);

Here is a snippet from the web.config

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_testservice">
          <security mode="Transport">
          </security>          
        </binding>
      </basicHttpBinding>      
    </bindings>
    <client>
      <endpoint address="https://endpointurl" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_testservice" contract="testws.testservice" name="BasicHttpBinding_testservice"/>
    </client>
  </system.serviceModel>

Also, I have tried making the request from SoapUI as follows:

   <soapenv:Header>
    <wsse:Security SOAP-ENV:mustUnderstand = "1" xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <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:UsernameToken>
    </wsse:Security>
  </SOAP-ENV:Header>

   <soapenv:Body>
      <tem:CancelService>
         <!--Optional:-->
         <tem:request>
            <!--Optional:-->
            <mod:Service_ID>test_service_id</mod:Service_ID>
            <mod:Provider_Ref>test_provider_ref</mod:Provider_Ref>
         </tem:request>
      </tem:CancelService>
   </soapenv:Body>
</soapenv:Envelope>

Doing this in SoapUI is giving me HTTP/1.1 500 Internal Server Error

which basically means that the request via SoapUI is hitting the server. What do I need to do to get at least the same error in my .net application.

Also, is there a way to capture the outgoing soap request in .net?

.net
http
soap
asked on Stack Overflow Mar 8, 2019 by user2260040 • edited Mar 8, 2019 by user2260040

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0