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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:35:59+00:00 2026-05-29T17:35:59+00:00

I am trying to invoke a webservice method which takes 2 input parameters and

  • 0

I am trying to invoke a webservice method which takes 2 input parameters and also needs a cookie to authenticate.

        PostMethod method = new PostMethod("webservice EP URL");
        NameValuePair code = new NameValuePair("Code", "");
        NameValuePair revision = new NameValuePair("Rev", "Latest");

        NameValuePair targetUri = new NameValuePair("TARGET", "GetObject");
        method.setRequestBody(new NameValuePair[] { code, revision,targetUri});
        int statusNew = client.executeMethod(method);

I dont know how to achieve it. Above code is what i am doing currently.

  • 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-29T17:36:01+00:00Added an answer on May 29, 2026 at 5:36 pm

    Using the SOAP Handler, we can pass the headers in the request and it will do the job.

    GetObject_Service_Impl impl = new GetObject_Service_Impl();
            // Get Iterator for all service ports
            Iterator iter = impl.getPorts();
    
            // Now create a new List of HandlerInfo objects - only one really.
            // Our client handler
            List handlerChain = new ArrayList();
            handlerChain.add(new HandlerInfo(SoapHandler.class, null, null));
    
            // Get Handler Registry
            HandlerRegistry registry = impl.getHandlerRegistry();
            // Register each port with the handler
            while (iter.hasNext())
                registry.setHandlerChain((QName) iter.next(), handlerChain);
    

    And Write a new class say SoapHandler.java as below

    public class SoapHandler extends GenericHandler {

    HandlerInfo hi;
    
    public void init(HandlerInfo info) {
        hi = info;
    }
    
    public QName[] getHeaders() {
        return hi.getHeaders();
    }
    
    public boolean handleResponse(MessageContext context) {
    
        return true;
    }
    
    /**
     * This method is use to add custom headers to existing SAOP request
     */
    public boolean handleRequest(MessageContext context) {
        System.out.println("response");
    
        try {
            SOAPMessageContext smc = (SOAPMessageContext) context;
            SOAPMessage message = smc.getMessage();
            MimeHeaders hd = message.getMimeHeaders();
            hd.addHeader("Authorization", "Basic some credentials");
    
        } catch (Exception e) {
            throw new JAXRPCException(e);
        }
        return true;
    }
    

    }

    And thats it…..its ready to go.

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

Sidebar

Related Questions

I am trying to create a simple webservice which takes a String as input
When trying to invoke a method on an external webservice (over the Internet) it
I'm trying to invoke a method that takes a super class as a parameter
I am trying to invoke a method via reflection with parameters and I get:
I am trying to use Desktop .browse() to invoke a URL, this works fine
How can I invoke a service directly from a view? I'm trying with ${my.domain.service.method}
When I'm trying get method from remote webservice it gives me error. My code
I am using ASP .Net 3.5 and trying to invoke a WebService using javascript
I'm trying to consume a web service created in .NET which needs SOAP authentication.
I am trying to create a webservice that takes data, posts it to a

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.