Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 587261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:11:38+00:00 2026-05-13T15:11:38+00:00

I have successfully created a WS client that works correctly when NOT using authentication.

  • 0

I have successfully created a WS client that works correctly when NOT using authentication.

However, the server (WebSphere) now requires adding a ws-security username token, and I’m having a hard time doing this. The resulting SOAP message is supposed to look something like this:

<soapenv:Envelope 
  xmlns:ns="http://foo.bar/1.0"
  xmlns:ns1="http://www.witsml.org/schemas/140"   
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

  <soapenv:Header>

    <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken wsu:Id="UsernameToken-2" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <wsse:Username>foo</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">bar</wsse:Password>    
        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">foooooobar==</wsse:Nonce>
        <wsu:Created>2010-01-25T13:09:24.860Z</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>

  </soapenv:Header>

  <soapenv:Body>
    <ns:fooBar>...</ns:fooBar>
  </soapenv:Body>

I’ve downloaded and installed Microsoft’s WSE 3.0 SDK and added a reference to the DLL in my Visual Studio 2005 project.

I now have access to the Microsoft.Web.Services3.* namespaces, but I’m currently stumped on how to proceed.

The client code has been generated automatically by a web reference, so I only do a minor amount of work to send the message to the server unauthenticated:

WS.FooResultHttpService ws = new WS.FooResultHttpService();
ws.Url = "http://foo.bar.baz";
ws.SendSomething(message);

I’ve just begun to investigate using Microsoft.Web.Services3.Security.Tokens.UsernameTokenManager, but so far I haven’t been able to get anything up and running.

Any hints would be greatly appreciated, as I can’t seem to find any good recipes on the net.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:11:39+00:00Added an answer on May 13, 2026 at 3:11 pm

    Got it working, unfortunately before reading wsanville’s great answer.

    To help others, I’m posting all the steps I needed to do to get it working with Visual Studio 2005:

    • Install WSE 3.0, choose custom and select everything
    • Read Implementing direct authentication with username token in WSE 3.0 for hints
    • Relaunch Visual Studio 2005, now right-click on your project in the solution explorer, and you should have a WSE Settings 3.0 menu item and use that if you want to.
    • Update your web references, this should create a new HTTP web service proxy class, with a different name, e.g. YourWsNameHttpServiceWse. This is essentially the same as running wsewsdl3.exe
    • Use this new class, and you should have access to WSE methods and properties, such as SetClientCredential.

    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:

    FooBarHttpServiceWse wse = new FooBarHttpServiceWse();
    
    wse.SetClientCredential(new UsernameToken(
        "username",
        "password",
        PasswordOption.SendPlainText));
    
    wse.SetPolicy(new FooBarPolicy());
    wse.CallSomeServerFunction(yourRequest)
    

    I created my own policy, which looked like this:

    using Microsoft.Web.Services3.Design;
    
    // ...
    
    public class FooBarPolicy : Policy
    {
        public FooBarPolicy()
        {
            this.Assertions.Add(new UsernameOverTransportAssertion());
        }
    }
    

    Finally, the WebSphere server responded that A required header representing a Message Addressing Property is not present, and inspecting the outgoing message (using the nice tool Fiddler) I saw the SOAP fault from the server indicated that the Action header was missing.

    I tried in vain to set the wsa:Action element myself:

    using Microsoft.Web.Services3.Addressing;
    
    // ...
    
    wse.RequestSoapContext.Addressing.Action = new Action("CallSomeServerFunction");
    

    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:

    [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(...)
    

    After that, it all worked out nicely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I successfully created an RMI service and client. I can call methods and so
The code below is the code i am using. It works fine in thunderbird
I have created an n-tier solution where I am retrieving related data from a
I have a web application which uses membership and profiles. I successfully used the
I have a Java web application that currently uses Log4J for logging. I'd like
I'm looking for any webservice client that can be run inside an OSGi container
I need to connect Apache Axis 1.4 to a Webservice that uses NTLM authentication
I'm currently developing a VSPackage, and it will have some log-in functionality external to
I am developing an OpenID consumer in PHP and am using the fantastic LightOpenID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.