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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:20:45+00:00 2026-05-19T02:20:45+00:00

I’m trying to consume a web service created in .NET which needs SOAP authentication.

  • 0

I’m trying to consume a web service created in .NET which needs SOAP authentication. The part that you would be most interested is this:

<s:element name="SoapAuthenticationHeader" type="tns:SoapAuthenticationHeader" /> 
      <s:complexType name="SoapAuthenticationHeader"> 
        <s:sequence> 
          <s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string" /> 
          <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" /> 
        </s:sequence> 
        <s:anyAttribute /> 
      </s:complexType> 

I’m able to successfully consume the web service in Netbeans. But I cannot use it because in the auto generated stub/methods, I cannot put the username and password for authentication.

Netbeans auto generated stub includes the following for:

JAX-WS

try { // Call Web Service Operation
            org.tempuri.TeleCast service = new org.tempuri.TeleCast();
            org.tempuri.TeleCastSoap port = service.getTeleCastSoap();
            // TODO initialize WS operation arguments here
            int campaignid = 0;
            java.lang.String to = "";
            java.lang.String from = "";
            java.lang.String subject = "";
            java.lang.String body = "";
            java.lang.String uniqueid = "";
            // TODO process result here
            boolean result = port.queueRealTimeEmail(campaignid, to, from, subject, body, uniqueid);
            System.out.println("Result = "+result);
        } catch (Exception ex) {
            // TODO handle custom exceptions here
        }

JAX-RPC

try { // This code block invokes the TeleCastSoap:queueRealTimeEmail operation on web service
            telecastclient.TeleCast teleCast = new telecastclient.TeleCast_Impl();
            telecastclient.TeleCastSoap teleCastSoap = teleCast.getTeleCastSoap();
            teleCastSoap.queueRealTimeEmail(/* TODO enter operation arguments*/);
        } catch(javax.xml.rpc.ServiceException ex) {
            java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch(java.rmi.RemoteException ex) {
            java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch(Exception ex) {
            java.util.logging.Logger.getLogger(telecastclient.TeleCast.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }

At the least when I use JAX-WS method, I get a class called SoapAuthenticationHeader in which I can set the username and password. But I don’t know how to pass that object of the SoapAuthenticationHeader before or while making the web service call to perform various operations.

org.tempuri.SoapAuthenticationHeader auth = new SoapAuthenticationHeader();
            auth.setUsername("username");
            auth.setPassword("password");

I do not have this option in JAX-RPC method.

Any inputs on this would be greatly appreciated. Thanks in advance for your time.

  • 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-19T02:20:46+00:00Added an answer on May 19, 2026 at 2:20 am

    Looks like there is no elegant way to do this from within the default Netbeans IDE.

    I was trying the same with Eclipse and in all my searches, I was lead to this Apache Axis2 – Code Generator Wizard Guide for Eclipse Plug-in for Eclipse (I still can’t post links as I’m a newbie).

    On using the above plugin (some sort of eclipse add-on of WSDL2Java), it generated the stubs along with proper SoapAuthenticationHeader objects which I can pass along for validation.

    So my code now is:

    TeleCastStub stub = new TeleCastStub();
    
    SoapAuthenticationHeader auth = new SoapAuthenticationHeader();
    auth.setUsername(username);
    auth.setPassword(password);
    
    QueueRealTimeEmail pageObj = new QueueRealTimeEmail();
    pageObj.setFrom(from);
    pageObj.setTo(to);
    pageObj.setSubject(subject);
    pageObj.setBody(body);
    
    SoapAuthenticationHeaderE authE = new SoapAuthenticationHeaderE();
    authE.setSoapAuthenticationHeader(auth);
    
    QueueRealTimeEmailResponse response = stub.queueRealTimeEmail(pageObj, authE);
    

    It works just fine.

    Now this leads me to a couple of more questions:

    1. The way I’ve gone about it, using
      the axis2 plugin, my code snippet,
      is it the right way to do it?
      Sometimes I get this feeling that I
      just put a hack together to get the
      job done and I’m always interested
      in finding the right way to do
      things so I can do it better next
      time.
    2. When I was using the in-built code
      generation wizard with eclipse, I
      noticed it had an option for Axis
      runtime and not Axis2. So now my
      question is; With older versions of
      Axis or with pre-built tools of the
      IDE, consuming web services with
      special authentication headers just
      can’t be done? Is it more of an architectural limitation?

    And thanks again for your time.

    Great board this one, SO! Has saved my hide numerous times. So it is my turn to give back to the community now.

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

Sidebar

Related Questions

No related questions found

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.