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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:04:59+00:00 2026-06-13T21:04:59+00:00

I’m getting a problem when trying to read the response from a web service

  • 0

I’m getting a problem when trying to read the response from a web service after using a POST request. I’m expecting to get some useful XML back, but instead all I am getting is HTML.

    URL url = new URL("https://abc.co.uk/someWS");
    String pKeyPassword = "xxxxxx";
    String xmlOutput = "someXML...";

    HttpsURLConnection con = (HttpsURLConnection) url.openConnection();

    //Load authentication certificate.
    KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
    KeyStore keyStore = KeyStore.getInstance("PKCS12");

    InputStream keyInput = new FileInputStream("/home/keystore.p12");
    keyStore.load(keyInput, pKeyPassword.toCharArray());
    keyInput.close();

    keyManagerFactory.init(keyStore, pKeyPassword.toCharArray());

    SSLContext context = SSLContext.getInstance("TLS");
    context.init(keyManagerFactory.getKeyManagers(), null, new SecureRandom());

    con.setSSLSocketFactory(context.getSocketFactory());

    // Tell the connection that we will be sending information
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setRequestProperty("Content-Length", "" + xmlOutput.length());
    con.setRequestProperty("Content-Type", "text/xml; UTF-8");
    con.setRequestMethod("POST");

    con.connect();

    // Send the POST stream data
    DataOutputStream outputStream = new DataOutputStream(con.getOutputStream());
    outputStream.writeBytes(xmlOutput);

    // Read the response
    InputStream inputstream = con.getInputStream();
    InputStreamReader inputstreamreader = new InputStreamReader(inputstream);
    BufferedReader bufferedreader = new BufferedReader(inputstreamreader);

    // format response to a string
    String string = null;
    String response = "";
    while ((string = bufferedreader.readLine()) != null) {
      response += string;
    }
    con.disconnect();
    System.out.println(response);

I’ve been assured that there is nothing wrong with the web service I am connecting to, and apparently it looks like from their end I’m trying to do a GET request (which will return HTML) rather than a POST request. Any idea whats wrong here?

  • 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-13T21:05:00+00:00Added an answer on June 13, 2026 at 9:05 pm

    Suppose if you got HTML, it might be some server error. Please, read server logs to detect that issue. Anyways, you can use soapUI application to verify that your Web Service defined and work properly.

    Here is snippets of code that worked for me (just add password):

    import org.apache.axis.AxisFault;
    import org.apache.axis.SOAPPart;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.message.SOAPEnvelope;
    import org.apache.axis.soap.MessageFactoryImpl;
    ....
    String mHostAddr = "yourURL";
    try {
    
            String envelope = getXML(); //redFromXmlFile();
            //String envelope = "";
            byte[] reqBytes = envelope.getBytes();
            ByteArrayInputStream bis = new ByteArrayInputStream(reqBytes);
            StreamSource ss = new StreamSource(bis);
    
            //Create a SOAP Message Object
            MessageFactoryImpl messageFactory = new MessageFactoryImpl();
            SOAPMessage msg = messageFactory.createMessage();
            SOAPPart soapPart = (SOAPPart) msg.getSOAPPart();
    
            //Set the soapPart Content with the stream source
            soapPart.setContent(ss);
    
            //Create a WebService Call
            Service service = new Service();
            Call call = (Call)service.createCall();
            call.setTargetEndpointAddress(mHostAddr);
    
            //Invoke the WebService.
            SOAPEnvelope resp = call.invoke(((org.apache.axis.SOAPPart)soapPart).getAsSOAPEnvelope());
    
    
    
    
    
    
        } catch (AxisFault ex) {
            System.out.println(ex.getMessage());
        } catch (ServiceException ex) {
            System.out.println(ex.getMessage());
        } catch (SOAPException ex) {
            System.out.println(ex.getMessage());
        } catch (RemoteException e) {
            e.printStackTrace();
        } 
    
    
    ....
    

    It might help you or find right direction

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I'm trying to create an if statement in PHP that prevents a single post
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am currently running into a problem where an element is coming back from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.