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: "http://www.shajisethu.com/schemas/VisitorService/getVisitors"
Host: sethu.homedns.org
Content-Type: multipart/related; type="application/xop+xml"; boundary=--MIMEBoundary632701497681437264; start="<0.632701497681437264@example.org>"; start-info="text/xml; charset=utf-8"
Content-Length: 1424
Expect: 100-continue
Proxy-Connection: Keep-Alive


----MIMEBoundary632701497681437264
content-id: <0.632701497681437264@example.org>
content-type: application/xop+xml; charset=utf-8; type="text/xml; charset=utf-8"
content-transfer-encoding: binary

http://www.shajisethu.com/schemas/VisitorService/getVisitorsurn:uuid:bd1fa634-e620-4649-a316-b7d64d80e71bhttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymoushttp://sethu.homedns.org/VisitorDataService/VisitorService.asmx2005-12-13T22:36:08Z2005-12-13T22:41:08Z
----MIMEBoundary632701497681437264--"

4 comments:

  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=3.0.0.0, 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.
    tim.
    http://tim.mackey.ie/

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

    Appreciate your help.

    ReplyDelete
  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...

    ReplyDelete
  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

    ReplyDelete