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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:32:00+00:00 2026-06-18T20:32:00+00:00

our webservice is used by a system that is not sending the message id

  • 0

our webservice is used by a system that is not sending the message id correctly. (not in the soap request at all!) I am looking for ways on how to add a message id if this is not
present in the actual call. If it is not present the entire call fails on the fact that a required property is not present.

Is there an easy way to accomplish this?

  • 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-06-18T20:32:01+00:00Added an answer on June 18, 2026 at 8:32 pm

    Found a solution here, but that doesn’t seem to work.

    Came up with this solution which works for me: create an interceptor which checks for the MessageID header and adds it to the message if it doesn’t exist:

    package my.package;
    
    import org.apache.cxf.binding.soap.SoapHeader;
    import org.apache.cxf.headers.Header;
    import org.apache.cxf.message.Message;
    import org.apache.cxf.phase.AbstractPhaseInterceptor;
    import org.apache.cxf.phase.Phase;
    import org.w3c.dom.Element;
    
    import javax.xml.namespace.QName;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.UUID;
    
    public class HeaderInterceptor extends AbstractPhaseInterceptor<Message> {
    
        private static final String SOAP_HEADER_KEY = "org.apache.cxf.headers.Header.list";
        private static final String NAMESPACE_URI   = "http://www.w3.org/2005/08/addressing";
        private static final String QUALIFIED_NAME  = "wsa:MessageID";
        private static final String LOCAL_NAME      = "MessageID";
    
        public HeaderInterceptor() {
            // phases: http://cxf.apache.org/docs/interceptors.html
            // 'pre protocol' seems to be the best moment to check the header, if we do it earlier the headers don't exist in the message object so we can't re-use the 'owner document'
            // if we do it later the unmarshalMAPs method (in MAPCodec.java) will already have processed the headers and will not process our added header
            super(Phase.PRE_PROTOCOL);
        }
    
        @Override
        public void handleMessage(Message message) throws Fault {
            ArrayList<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY);
    
            // if the header doesn't exist and we have at least one header to access 'owner document' we can create and add our own MessageID header
            if(!messageIdHeaderExists(headers) && headers.size() > 0) {
                Element existingHeaderElement = (Element) headers.get(0).getObject();
    
                // use the existing header element to create our own MessageID header with random UUID
                Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME);
                element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString()));
    
                QName qname = new QName(NAMESPACE_URI, LOCAL_NAME);
                SoapHeader header = new SoapHeader(qname, element);
    
                // by default a SoapHeader is created with 'direction out'
                header.setDirection(Header.Direction.DIRECTION_IN);
    
                headers.add(header);
            }
        }
    
        /**
         * Checks if the MessageID header exists in the list of headers.
         *
         * @param headers list of headers
         * @return true if the MessageID header exists, false if not
         */
        private Boolean messageIdHeaderExists(ArrayList<SoapHeader> headers) {
            for(SoapHeader header:headers) {
                if(header.getName().getLocalPart().equalsIgnoreCase(LOCAL_NAME)) {
                    return true;
                }
            }
            return false;
        }        
    
    }
    

    Define the interceptor in your Spring context:

    <bean id="headerInterceptor" class="my.package.HeaderInterceptor" />
    
    <jaxws:endpoint implementor="#service" address="/ws">
        <jaxws:inInterceptors>
            <ref bean="headerInterceptor" />
        </jaxws:inInterceptors>
    </jaxws:endpoint>
    

    Tested with CXF version 2.6.1.
    More info on interceptors: http://cxf.apache.org/docs/interceptors.html

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

Sidebar

Related Questions

I'm working on a project where I'm trying to send request to our webservice
In one of our applications we need to call the Yahoo Soap Webservice to
Im currently developing a Silverlight application that connects to an old webservice. Our old
I have written a MVC web application that is used on our corporate intranet.
Our system communicates with several web services providers. They are all invoked from a
We have an API that will be only used by our new website for
We're currently building a system that abstracts all kinds of technical details about web
We've been using Jersey for our webservice and it's been great and straightforward. Is
As we are working locally so our service link is: http://localhost:8012/webservice.asmx When we deploy
We are about to update our Primavera system from 6.x to 8.2. We have

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.