Wednesday, December 14, 2005

WSE 3.0 and MTOM

Over my holidays I started playing with WSE 3.0 and VS 2005. As part of the exercise built a simple web service that would allow people to send pictures and view pictures. All worked well till I enabled MTOM on the services. Since then everything the client tries to connect to the service it gets the following message "The request failed with HTTP status 415: Unsupported Media Type.". I have looked around in newsgroups and not found any resolution. BTW the web services is hosted inside IIS running on XP pro with SP2, have not tries if it will work on VS 2005 inbuilt web server (had I chosen directory option instead of web server).

For now I have decided to move on if any of you find a resolution do let me know, if I find it will post it here.

The raw messages is below that is sent to server
"POST /VisitorDataService/VisitorService.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.42)
VsDebuggerCausalityData: uIDPo4jPn8RWmPlAjcQTkQgpUHMAAAAAX7/rVlC6HkyUzBUqLrewxBLVzD4GiL1Cips5Q4ONci0ACAAA
SOAPAction: ""
Content-Type: multipart/related; type="application/xop+xml"; boundary=--MIMEBoundary632701497681437264; start="<>"; start-info="text/xml; charset=utf-8"
Content-Length: 1424
Expect: 100-continue
Proxy-Connection: Keep-Alive

content-id: <>
content-type: application/xop+xml; charset=utf-8; type="text/xml; charset=utf-8"
content-transfer-encoding: binary


  1. hi Shaji,
    i also encountered this error in my web application. with some research, i found out that i was missing one line from my web.config:
    <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    it belongs in the section:
    system.web ... webServices

    once i added this, the web service worked perfectly.

    hope this helps your scenario.

  2. Tim,
    Thanks for your help. I added that line to the web.config and it worked like a charm.

    Appreciate your help.

  3. I'm receiving the same error, but adding that line to my web.config (which the VS2005 add-in does automatically) didn't fix it; I can't get a .NET WSE 3.0 client to send data via MTOM to a .NET WSE 3.0 service. When I set serverMode=optional, the communication is successful, but if I do a TCP trace, I can see that MTOM is not being utilized (it's just base64). If I set serverMode=always, I get a 415: Unsupported Media Type error, both from IIS and from the built-in VS2005 web server.

    I also receive the same 415: Unsupported Media Type error from a JAX-WS 2.0 Java client trying to talk to this WSE 3.0 service.

    Does anyone have a complete, working example of this that is 100% verified to actually be using MTOM under the hood? I'm guessing that the only reason people have been getting this to work is that, if you actually did a TCP trace, you'd see that MTOM isn't even being used...

  4. In VS2005 with a forms client, the generated proxy class inherits from System.Web.Services.Protocols.SoapHttpClientProtocol and thus does not use WSE3 (ie. no MTOM encoding).

    You need to manually edit the proxy and change it to inherit from Microsoft.Web.Services3.WebServicesClientProtocol.

    To see the generated proxy class in VS click on the web reference and then click the 'Show All Files' toolbar button.

    However, with a web based client VS2005 generates 2 proxy classes, the standard one and one with 'Wse' suffix that inherits from Microsoft.Web.Services3.WebServicesClientProtocol