Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Got it working, unfortunately before reading <a href="https://stackoverflow.com/questions/2139190/adding-soapheader-username-and-password-with-wse-3-0/2139480#2139480">wsanville's great answer</a>.</p> <p>To help others, I'm posting all the steps I needed to do to get it working with Visual Studio 2005:</p> <ul> <li>Install <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=018a09fd-3a74-43c5-8ec1-8d789091255d&amp;displaylang=en" rel="nofollow noreferrer">WSE 3.0</a>, choose <em>custom</em> and select everything</li> <li>Read <a href="http://msdn.microsoft.com/en-us/library/aa480575.aspx" rel="nofollow noreferrer">Implementing direct authentication with username token in WSE 3.0</a> for hints</li> <li>Relaunch Visual Studio 2005, now right-click on your project in the solution explorer, and you should have a <em>WSE Settings 3.0</em> menu item and use that if you want to.</li> <li>Update your web references, this should create a new HTTP web service proxy class, with a different name, e.g. <code>YourWsNameHttpServiceWse</code>. This is essentially the same as running <a href="http://msdn.microsoft.com/en-us/library/aa529578.aspx" rel="nofollow noreferrer">wsewsdl3.exe</a></li> <li>Use this new class, and you should have access to WSE methods and properties, such as <code>SetClientCredential</code>.</li> </ul> <p>I ended up doing almost everything in code, instead of relying on the config-files that are built with my C# DLL. The code ended up looking like this:</p> <pre><code>FooBarHttpServiceWse wse = new FooBarHttpServiceWse(); wse.SetClientCredential(new UsernameToken( "username", "password", PasswordOption.SendPlainText)); wse.SetPolicy(new FooBarPolicy()); wse.CallSomeServerFunction(yourRequest) </code></pre> <p>I created my own policy, which looked like this:</p> <pre><code>using Microsoft.Web.Services3.Design; // ... public class FooBarPolicy : Policy { public FooBarPolicy() { this.Assertions.Add(new UsernameOverTransportAssertion()); } } </code></pre> <p>Finally, the WebSphere server responded that <em>A required header representing a Message Addressing Property is not present</em>, and inspecting the outgoing message (using the nice tool <a href="http://www.fiddler2.com/fiddler2/" rel="nofollow noreferrer">Fiddler</a>) I saw the SOAP fault from the server indicated that the Action header was missing.</p> <p>I tried in vain to set the <code>wsa:Action</code> element myself:</p> <pre><code>using Microsoft.Web.Services3.Addressing; // ... wse.RequestSoapContext.Addressing.Action = new Action("CallSomeServerFunction"); </code></pre> <p>The problem was that even if I set an action, when it was sent over the wire, it was empty. Turned out I had to open the WSE proxy class and edit an attribute there:</p> <pre><code>[System.Web.Services.Protocols.SoapDocumentMethodAttribute( "---Edit this to set wsa:Action---", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)] // ... public SomeServerFunction(...) </code></pre> <p>After that, it all worked out nicely. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload