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

  • Home
  • SEARCH
  • 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 638991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:47:34+00:00 2026-05-13T20:47:34+00:00

I am trying to create a standalone client to consume some web services. I

  • 0

I am trying to create a standalone client to consume some web services. I must add my username and password to the SOAP Header. I tried adding the credentials as follows:

OTSWebSvcsService service = new OTSWebSvcsService();
OTSWebSvcs port = service.getOTSWebSvcs();

BindingProvider prov = (BindingProvider)port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "myusername");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "mypassword");

...

When I call a method on the service I get the following exception:

com.ibm.wsspi.wssecurity.SoapSecurityException: WSEC5048E: One of "SOAP Header" elements required.

What am I doing wrong? How would I add these properties to the SOAP Header?

Edited: I was using JAX-WS 2.1 included in JDK6. I am now using JAX-WS 2.2. I now get the following exception:

com.ibm.wsspi.wssecurity.SoapSecurityException: WSEC5509E: A security token whose type is [http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken] is required.

How do I go about creating this token?

  • 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-13T20:47:34+00:00Added an answer on May 13, 2026 at 8:47 pm

    Not 100% sure as the question is missing some details but if you are using JAX-WS RI, then have a look at Adding SOAP headers when sending requests:

    The portable way of doing this is that
    you create a SOAPHandler and mess
    with SAAJ, but the RI provides a
    better way of doing this.

    When you create a proxy or dispatch
    object, they implement
    BindingProvider interface. When you
    use the JAX-WS RI, you can downcast to
    WSBindingProvider which defines a
    few more methods provided only by the
    JAX-WS RI.

    This interface lets you set an
    arbitrary number of Header object,
    each representing a SOAP header. You
    can implement it on your own if you
    want, but most likely you’d use one of
    the factory methods defined on
    Headers class to create one.

    import com.sun.xml.ws.developer.WSBindingProvider;
    
    HelloPort port = helloService.getHelloPort();  // or something like that...
    WSBindingProvider bp = (WSBindingProvider)port;
    
    bp.setOutboundHeader(
      // simple string value as a header, like <simpleHeader>stringValue</simpleHeader>
      Headers.create(new QName("simpleHeader"),"stringValue"),
      // create a header from JAXB object
      Headers.create(jaxbContext,myJaxbObject)
    );
    

    Update your code accordingly and try again. And if you’re not using JAX-WS RI, please update your question and provide more context information.

    Update: It appears that the web service you want to call is secured with WS-Security/UsernameTokens. This is a bit different from your initial question. Anyway, to configure your client to send usernames and passwords, I suggest to check the great post Implementing the WS-Security UsernameToken Profile for Metro-based web services (jump to step 4). Using NetBeans for this step might ease things a lot.

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

Sidebar

Ask A Question

Stats

  • Questions 315k
  • Answers 315k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Actually it's not that hard if you subclass TableLayout like… May 13, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer I would think the main view model is the right… May 13, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer The std::ostream class requires a std::streambuf object for its output.… May 13, 2026 at 11:11 pm

Related Questions

I am currently trying to wrap my mind around Java EE 5. What I'd
I'm running JBoss 4.2.3, Java 1.5, and Ubuntu. Before you tell me to post
I am trying to create an mac application in XCode that has some of
I am calling my makewindows function from a PHP file like so: echo <a
I am creating a new table in Microsoft SQL server 2000 by writing the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.