none
SOAP 400 BAD request RRS feed

  • Question

  • , IHello,

    I an (very) new to writing a SOAP posting client, so please bear with me if this is a silly question.

    I have written a Windows Forms C# program to POST a SOAP request to a web service, but when I do I get the response :

    HTTP/1.1 400 Bad Request
    Date: Wed, 17 Jan 2018 12:26:23 GMT
    Server: Apache
    Content-Length: 356
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>400 Bad Request</title>
    </head><body>
    <h1>Bad Request</h1>
    <p>Your browser sent a request that this server could not understand.<br />
    Request header field is missing ':' separator.<br />
    <pre>
    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</pre>
    </p>
    </body></html>
    
    

    my SOAP request (called data.txt) looks like

    POST /Folder1/Suppliers HTTP/1.1
    Host: domainname.com
    Content-Type: text/xml; charset=utf-8
    Content-Length: 571
    SOAPAction: "http://domainname.com/Folder1/Suppliers"
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:impl="http://impl.wsSuppliers.integracion/">
    <soapenv:Header/>
    <soapenv:Body>
    <impl:getSuppliersRQ>
    <impl:getSuppliersRQRow>
    <impl:idClie>########</impl:idClie>
    <impl:pwClie>--------</impl:pwClie>
    <impl:CHM>@@@@@@@@@@@@</impl:CHM>
    </impl:getSuppliersRQRow>
    </impl:getSuppliersRQ>
    </soapenv:Body>
    </soapenv:Envelope>

    NB: I have obviscated some sensitive data.

    if I remove everything from the <?xml line upwards (the services' manual only lists the lines  from <soapenv:Envelope onwards), then it takes longer to error, and I get :

    HTTP/1.1 400 Bad Request
    Date: Wed, 17 Jan 2018 13:33:11 GMT
    Server: Apache
    Content-Length: 226
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
    
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>400 Bad Request</title>
    </head><body>
    <h1>Bad Request</h1>
    <p>Your browser sent a request that this server could not understand.<br />
    </p>
    </body></html>
    

    If i just remove <?xml version="1.0" encoding="UTF-8"?>, then i get the same "<p>Your browser sent a request that this server could not understand.<br />" message.

    Can someone tell me what's wrong with line <?xml version="1.0" encoding="UTF-8"?> , or what i am doing wrong with my SOAP request ?

    thanks

    • Moved by Fei Hu Monday, January 22, 2018 11:20 AM ASP.NET related
    Wednesday, January 17, 2018 1:57 PM

All replies

  • It is strongly recommended that you don't try to build soap messages by hand. Use service references or a SOAP library to make these calls. It is simpler.

    The actual error in the response is this

    Request header field is missing ':' separator

    That means you send a header that was of the form key value instead of the expected key : value

    The request header is not your SOAP envelope. It is the request header that is configured using the Headers property of the client. Most likely you are trying to send some authentication information and you are not sending it in the expected format. Hence the error.  I would recommend that you use Fiddler or similar network tool to send a valid SOAP request to your endpoint. Then take a look at the headers that are sent. That is what you need to send in your code as well.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, January 17, 2018 3:36 PM
  • SOAP Web services and other Web services can be addressed at the below forum.

    https://forums.asp.net/28.aspx/1?WCF+ASMX+and+other+Web+Services

    Wednesday, January 17, 2018 4:03 PM
  • thank you, I'll move it over to there.
    Wednesday, January 17, 2018 6:32 PM
  • thank you, i'll check fiddler out
    Wednesday, January 17, 2018 6:33 PM
  • Hi G-Oker,

    According to your question is more related to Asp.Net, you could repost a new thread to asp.net forum for suitable support.

    The Visual C# discuss and ask the C# programming language, IDE, libraries, samples and tools. If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

    Best Regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 22, 2018 11:19 AM