Note that there are some explanatory texts on larger screens.

plurals
  1. PORequests are getting wrapped with CDATA
    primarykey
    data
    text
    <p>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</p> <pre><code>&lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;s:Header&gt; &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/ITransferService/getInt&lt;/Action&gt; &lt;/s:Header&gt; &lt;s:Body&gt; &lt;getInt xmlns="http://tempuri.org/"&gt; &lt;i&gt;42&lt;/i&gt; &lt;/getInt&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt; </code></pre> <p>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.</p> <pre><code>&lt;MessageLogTraceRecord&gt;&lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;s:Header&gt; &lt;Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://tempuri.org/ITransferService/getInt&lt;/Action&gt; &lt;/s:Header&gt; &lt;s:Body&gt; &lt;getInt xmlns="http://tempuri.org/"&gt; &lt;i&gt;100&lt;/i&gt; &lt;/getInt&gt; &lt;/s:Body&gt; &lt;/s:Envelope&gt; ]]&gt;&lt;/MessageLogTraceRecord&gt; </code></pre> <p>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.</p> <pre><code>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()); } </code></pre> <p>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</p> <p>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?</p> <p>Thanks Nick Long</p> <p>edit: I changed this line</p> <pre><code>connection.setRequestProperty("content-type", "text/html; charset=utf8"); </code></pre> <p>to this</p> <pre><code>connection.setRequestProperty("content-type", "text/xml"); </code></pre> <p>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</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload