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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:22:45+00:00 2026-05-30T11:22:45+00:00

I am working on a java client for WCF, and have the template worked

  • 0

I am working on a java client for WCF, and have the template worked out pretty good. I was initially using the web service client project from eclipse but then found out the libraries needed aren’t supported on the android platform. I was then going to use ksoap, but it gave me a lot of issues, so I got a copy of a working soap request

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ITransferService/getInt</Action>
  </s:Header>
  <s:Body>
    <getInt xmlns="http://tempuri.org/">
      <i>42</i>
    </getInt>
  </s:Body>
</s:Envelope>

And decided to make a template that would take in the value and stick it where the 42 goes. When I print it out, it looks like it should work great, but I noticed when I trace that my request is wrapped in CDATA tags.

<MessageLogTraceRecord><![CDATA[<?xml version="1.0" encoding="utf-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
            <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ITransferService/getInt</Action>
        </s:Header>
        <s:Body>
            <getInt xmlns="http://tempuri.org/">
                <i>100</i>
            </getInt>
        </s:Body>
    </s:Envelope>
]]></MessageLogTraceRecord>

I am not sure why it is wrapped in CDATA, I am using a HttpURLConnection to make and send the connection. The code that handles that is shown below.

private static void sendRequest(String request) throws Exception
    {
        URL u = new URL(DEFAULT_SERVER);
        URLConnection uc = u.openConnection();
        HttpURLConnection connection = (HttpURLConnection)uc;

        connection.setRequestProperty("content-type", "text/html; charset=utf8");

        connection.setDoOutput(true);
        connection.setDoInput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("SOAPAction",SOAP_ACTION);

        OutputStream out = connection.getOutputStream();
        Writer wout = new OutputStreamWriter(out);

        wout.write(request);
        wout.flush();
        wout.close();
        System.out.println(connection.getResponseMessage());
    }

The request variable is what is shown above, at least what is wrapped in the CDATA tags. When I call System.out.println(connection.getResponseMessage()); then it tells me Unsupported Media Type.
I am using Text as the messageEncoding in my binding configuration for the WCF server

Does anyone have any suggestions as to how I could get my java client to send the data correctly rather than in a cdata wrapper?

Thanks
Nick Long

edit:
I changed this line

connection.setRequestProperty("content-type", "text/html; charset=utf8");

to this

connection.setRequestProperty("content-type", "text/xml");

like it probably should have been to start with. I now get a 500 internal server error, so I’m not sure if I am any closer or not. Any suggestions are still really appreciated

  • 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-30T11:22:46+00:00Added an answer on May 30, 2026 at 11:22 am

    The first change I made was this:

    connection.setRequestProperty("content-type", "text/html; charset=utf8");
    

    to this

    connection.setRequestProperty("content-type", "text/xml");
    

    That was what got rid of the 415 error. After that I had the 500 error. What I did to fix that was I took this line

    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/ITransferService/getInt</Action>
    

    and removed it, making my template this:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
        <s:Header>
        </s:Header>
        <s:Body>
            <getInt xmlns="http://tempuri.org/">
                <i>%val%</i>
            </getInt>
        </s:Body>
    </s:Envelope>
    

    The reason, I believe (someone please correct me if I am wrong) that I was getting the 500 error was that I had this line and the line I removed:

    connection.setRequestProperty("SOAPAction",SOAP_ACTION);
    

    After making those changes, my client works great, and I have been able to take it to an image sharing client for the android.

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

Sidebar

Related Questions

I am working on an IMAP client using java mail. We currently have a
I have created a couple of java working sets for a project in my
I have a working java client that is communicating with Google, through ProtoBuf serialized
I'm working on a project that include both Java (on the client side) and
I have to call SharePoint 2010 Lists service from a Java client. I used
I am working on a project where there is a Java client that needs
I'm working on a Java 6 application server which has a web service for
I am working on a web start client in java. I need to connect
I am working in Java on a fairly large project. My question is about
I have been working with Java a couple of years, but up until recently

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.