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 114913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:56:10+00:00 2026-05-11T02:56:10+00:00

So I need to consume a Web Service that uses a custom SoapHeader, as

  • 0

So I need to consume a Web Service that uses a custom SoapHeader, as described below. What is the simplest way to pass the correct values through this header using Java. I’m using Netbeans.

<?xml version='1.0' encoding='utf-8'?\> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>   <soap:Header>     <CustomSoapHeader xmlns='http://snip'>       <UserName>'string'</UserName>       <Password>'string'</Password>     </CustomSoapHeader>   </soap:Header>   <soap:Body>     <SomeWebMethod xmlns='http://snip' />   </soap:Body> </soap:Envelope> 

EDIT: What’s the best way to display XML on Stack Overflow?

It might help to add that the Web Service is implemented in .NET and I cannot change the server side code.

  • 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. 2026-05-11T02:56:11+00:00Added an answer on May 11, 2026 at 2:56 am

    Here are the basic steps, assuming you’re doing this on the client side:

    • Install a HandlerResolver on your service interface (service.setHandlerResolver())
    • Override HandlerResolver.getHandlerChain() to insert your own implementation of SOAPHandler
    • Implement SOAPHandler.handleMessage() to modify the SOAP header before it’s sent out

    You can pass parameters to your handler through the request context:

    Map<String, Object> context = ((BindingProvider) port).getRequestContext(); context.put('userName', 'foo'); ... 

    in handleMessage() you can get at the header like this:

    public boolean handleMessage(SOAPMessageContext context) {     ...      SOAPMessage msg = context.getMessage();     msg.getSoapHeader();     ...  } 

    Hope that helps. I’m guessing there’s also a way to do this stuff with annotations as well.

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

Sidebar

Related Questions

I need to consume a Web Service via SSL. In order to accomplish that
I need to implement a project that will consume XML Web Service from other
I have a web service that I need to consume from BizTalk orchestration. I've
I need to consume a web service from android/eclipse by soap method. ie., i
I need to connect to another web application using webservice. That web application uses
I need to consume a SOAP web service from a C# .Net 4.0 client.
I need to write an application (not a sevrice or web service) that consumes
I'm about to develop widget that will consume a web service built on top
Hers my problem: we have a web service that we need to invoke from
I am writing a biztalk orchestration that will need to call a web service,

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.