none
415 status code from WCF Web Service RRS feed

  • Question

  • Hi,

                I am invoking a WCF Web Service URL https://host/Service.svc. My client is Apache HttpClient.

            post.setRequestHeader("Accept", "application/soap+xml,multipart/related,text/*");
            post.setRequestHeader("Content-Type", "application/soap+xml,multipart/related,text/*");
            post.setRequestHeader("SOAPAction", "http://uri.org/IActionService/Save");
    post.setRequestHeader("Cache-Control", "no-cache");
            post.setRequestHeader("Pragma", "no-cache");

    I get ' The server cannot service the request because the media type is unsupported.'

    I pass my entire SOAP envelope to this service and assume there is no authentication issue. I believe that is resolved.

    What could cause this status code to be returned ?

    My SOAP envelope starts with

    <?xml version=\"1.0\" encoding=\"utf-8\" ?>

    followed by the envelop contents including the SOAP header , SOAP body etc. Even though the SOAP envelope has the headers

    I also set a request header in code shown above.

    Can I request for a basic SOAP envelope that is passed to a WCF service ?

    Thanks,

    Mohan

    Wednesday, November 1, 2017 3:30 PM

All replies

  • HTTP 415 is invalid media type error. Unless you are being told that a WCF Web service is using SOAP, then any WCF SOA solution is using XML and not SOAP as the media type, the default.
    Wednesday, November 1, 2017 3:47 PM
  • Hi Mohan,

    Could you share us how you develop WCF Service? As the reply from DA924x, your issue is related with media type.

    In general, SOAP 1.1 sends text/xml and SOAP 1.2 sends application/soap+xml by default. You may try to set content type with “text/xml” or “application/soap+xml”.

    I suggest you check below link.

    # Sending HTTP Post request with SOAP action using org.apache.http

    https://stackoverflow.com/questions/10671494/sending-http-post-request-with-soap-action-using-org-apache-http

    Best Regards,

    Edward


    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.

    Thursday, November 2, 2017 2:34 AM
  • Hello,

           The WCF service is owned by a different team.

           text/xml returns 'Bad Request"

           applciation.xml returns 415

          Headers from the server are these.

          Cache-Control private
    10:09:38.269 INFO  [main] Script1.run[:43] - Content-Type text/html
    10:09:38.269 INFO  [main] Script1.run[:43] - Server Microsoft-IIS/7.5
    10:09:38.269 INFO  [main] Script1.run[:43] - X-AspNet-Version 2.0.50727
    10:09:38.269 INFO  [main] Script1.run[:43] - ServerName MYSERVER
    10:09:38.269 INFO  [main] Script1.run[:43] - X-Powered-By ASP.NET
    10:09:38.269 INFO  [main] Script1.run[:43] - Date Thu, 02 Nov 2017 04:39:37 GMT
    10:09:38.284 INFO  [main] Script1.run[:43] - Content-Length 76

    Shouldn't it be sending what type it accepts as a header "

    Thanks,

    Mohan

    Thursday, November 2, 2017 4:42 AM
  • Hi Mohan,

    Before trying every possibility, I would suggest you contact the WCF Service developer to confirm the supported media type and right SOAP Request. No body will know these information except the service developer.

    At present, your issue is not related with HttpClient, it is related with which SOAP request could be accepted by the service.

    Best Regards,

    Edward


    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.

    Thursday, November 2, 2017 5:26 AM
  • So finally when I used the SOAP UI I found it is sending "text/html ; charset UTF-8" and it returned a response.

    This reminds me to look up all the SOAP faults and other status codes that could bog us down. 

    Nowadays I find more REST references than SOAP references. 

    Thanks,

    Mohan

    Friday, November 3, 2017 2:06 PM
  • Hi Mohan,

    It seems your issue is resolved by changing to "text/html;charset UTF-8", if so, I would suggest you mark the helpful reply as answer which is the way to close a thread here.

    Best Regards,

    Edward


    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, November 6, 2017 2:02 AM