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

Related Questions

I'm trying to create a standalone HTML5 document that utilizes SQlite or some other
I am trying to implement jdbc-pool in a standalone web app (self contained -
I'm trying to create a standalone app using JBoss Microcontainer for IoC and JBoss
I am trying to create an mac application in XCode that has some of
I'm trying to create users in WebLogic (10.3.4) programmatically from a simple standalone Java
I am trying to create a standalone jar file I don't think that maven
I'm trying to create a standalone HTML5 document that utilizes SQlite. I want to
I'm trying to create some kind of callback code which gets executed after an
I'm trying to create a standalone JAR containing Akka, Spray, and Jetty. Ideally I
I'm trying to create a datasource in JBOSS 7. My standalone.xml excerpts: <subsystem xmlns=urn:jboss:domain:datasources:1.0>

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.