RSS Feed for This PostCurrent Article

.NET: MTOM Enabled Your Application Using WSE

One of my user encountered the following error when he is trying to use .NET to connect to the web services which are running under Apache CXF.

Client found response content type of 'multipart/related; type="application/xop+
xml"; boundary="----=_Part_0_9519730.1210566764662"; start="<[email protected]
ache.org>"; start-info="application/soap+xml"', but expected 'application/soap+x
ml'.
The request failed with the error message:
--
 
------=_Part_0_9519730.1210566764662
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml; ch
arset=UTF-8"
Content-Transfer-Encoding: binary
Content-ID: [email protected]
 

The web services have attachment and in order to consume them, the .NET web service client must be MTOM enabled, which is the part that caused the confusion.

The user claimed that he is using WSE 3.0 but obviously is not.

The Web Services Enhancements for Microsoft .NET (WSE) enables developers to create interoperable Web services with advanced Web services features. With WSE 3.0, you can secure your messages using digital signatures and encryption, use MTOM to efficiently send large amounts of binary data, route messages through intermediaries, host Web Services outside of IIS, use the TCP/IP protocol and more.

To take full advantage of WSE, I would advise you to install everything using the Custom installation option, which will integrate it with Visual Studio.

wse_setup

You may encounter the issue whereby WSE Settings Tool does not appear on the Visual Studio 2005 Solution Explorer content menu. This occurs if you install Visual Studio 2005 and then install WSE 3.0 without first having started Visual Studio 2005. Ensure that you start Visual Studio 2005 before installing WSE 3.0. Alternatively you can use the Visual Studio 2005 Add-in Manager available from the Tools menu item to manually install the WSE 3.0 Settings tool if you do install WSE 3.0 without having started Visual Studio 2005 first.

Alternatively you can also start the WSE Configuration Tool manually from the Start Menu, use it to open your web.config or App.config to configure the WSE settings.

To MTOM-enabled your application, right click on your project Properties, and click on WSE 3.0 Settings.

image

You must check on the Enable this project for Web Service Enhancements.

image

Also set the Client Mode to On for MTOM Settings

image

After this you can add a web reference to the web services WSDL. This will generate the proxy class for it. Make sure the proxy class for WSE inherits from Microsoft.Web.Services3.WebServicesClientProtocol instead of System.Web.Services.Protocols.SoapHttpClientProtocol. Sometimes the proxy class for WSE is not generated.

public partial class MyServices : Microsoft.Web.Services3.WebServicesClientProtocol


Trackback URL


RSS Feed for This Post4 Comment(s)

  1. Keith Losset | Jun 6, 2008 | Reply

    While not using WSE would certainly be a problem, an exhaustive search of WSE839 errors tells me that there are many people that are using WSE30 properly (with the settings you suggest) that get the same or a similar error. In fact, based on the web searches, it is not clear that anyone is able to get MTOM interop to work between a NET 2.0/WSE 3.0 client and any Java-based server side implementation.

    Your article is by far the most encouraging. I am curious what success stories or follow-up comments you or your readers might have?

  2. Haris | Jul 10, 2008 | Reply

    “Sometimes the proxy class for WSE is not generated.”

    I am facing the same problem.

    Does this mean that Client is not configured properly or is it have something to do with Web Service???

    Please advise.

  3. Mucahid Uslu | Aug 21, 2008 | Reply

    After install Microsoft WSE 3.0, you must add to project reference Microsoft.Web.Services3.

    Mucahid Uslu

  4. Leng Keng | Oct 5, 2008 | Reply

    If you made changes to the proxy classes, you should remove the web reference and start anew. After the web reference is added back, try to use the one with class name ‘xxxWse’ to ensure that MTOM is enabled.

    If the xxxWse class is still missing, you can click on “view all files” icon in the Solution Explorer, then navigate to the reference.cs file of your web reference. Manually change both the proxy class definition and method definition to public from abstract. Finally, change the class to inherit from ‘Microsoft.Web.Services3.WebServicesClientProtocol’ instead of ‘System.Web.Services.Protocols.SoapHttpClientProtocol’. Hope this helps.

Sorry, comments for this entry are closed at this time.