cancel
Showing results for 
Search instead for 
Did you mean: 

Soap Adapter : Encoding

Former Member
0 Kudos

Hi guys,

I'm having problems sending characters such as é ç è ô ... to my soap adapter. My scenario is that I am using a servlet to encode my soap envelop and then i'm sending it to my soap adapter. Here is a sample of my code :


HttpURLConnection connection = null;			
StringBuffer sb = new StringBuffer();

...

sb.append(mapProp.getProperty(SOAP_BEG_ENVL));
				sb.append(mapProp.getProperty(SOAP_BEG_BODY));
				sb.append(mapProp.getProperty(SOAP_BEG_MT));
				sb.append(mapProp.getProperty(SOAP_BEG_HDR));
				sb.append(mapProp.getProperty(SOAP_BEG_INST)
						  + confProp.getProperty(INSTITUTION)
						  + mapProp.getProperty(SOAP_END_INST));
				sb.append(mapProp.getProperty(SOAP_BEG_DATE)
						  + date				
						  + mapProp.getProperty(SOAP_END_DATE));
				sb.append(mapProp.getProperty(SOAP_BEG_TIME)
		  	  			  + time
						  + mapProp.getProperty(SOAP_END_TIME));	  
						  
				sb.append(mapProp.getProperty(SOAP_END_HDR));
				
				sb.append(mapProp.getProperty(SOAP_BEG_DETAIL));
				

				buffReader = request.getReader();
				do {

					data = buffReader.readLine();
					if (data != null) {
						data = data.replaceAll("&", "&");
						data = data.replaceAll("<", "<");
						data = data.replaceAll(">", ">");
						data = data.replaceAll(""", """);
						data = data.replaceAll("'", "&apos;");
					
					sb.append(mapProp.getProperty(SOAP_BEG_DATA)
							  + data
							  + mapProp.getProperty(SOAP_END_DATA));
					}
				}
				while(data != null);

				
				sb.append(mapProp.getProperty(SOAP_END_DETAIL));
				sb.append(mapProp.getProperty(SOAP_END_MT));
				sb.append(mapProp.getProperty(SOAP_END_BODY));
				sb.append(mapProp.getProperty(SOAP_END_ENVL));
				
				
				//java.net.Authenticator.setDefault(new Auth());
				
				url = new URL(confProp.getProperty(HTTP_URL));
				connection = (HttpURLConnection) url.openConnection();

				connection.setDoInput(true);
				connection.setDoOutput(true);
				connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
				connection.setRequestProperty("Content-Type","text/xml; charset=ISO-8859-1");
				connection.setRequestProperty("SOAPAction","SomeAction");
				connection.setRequestMethod( "POST" );

				Charset cs = Charset.forName("ISO-8859-1");

				out = connection.getOutputStream();
				OutputStreamWriter osw = new OutputStreamWriter(out, cs);
				
				
				osw.write(sb.toString().toCharArray());
				osw.close();
				out.close();
...

This is the error message I get back from my client :

java.io.IOException: Server returned HTTP response code: 400 for URL: https://XXXXX.wshs.:3405/dev/RM/Sync/Procurement

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:814)

at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(DashoA12275)

at App.main(App.java:117)

I have no problems when their are no accented characters.

thanks for your help.

Steeve

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

How do you do that? I''m passing the charset via the web service but it has no affect.

Thanks

Steeve

Former Member
0 Kudos

Hi,

How do you do that? I''m passing the charset via the web service but it has no affect.

Thanks

Steeve

Former Member
0 Kudos

Hi,

You are using a sender soap adapter right?

If so, you need to enter the encoding as part of the url and not in the module.

http://host:port /XISOAPAdapter/MessageServlet?channel<b>=...&xmlenc=iso-8859-1</b>

Regards,

Smitha.

Former Member
0 Kudos

Thanks. I was already using it. It's probably a bug in the soap sender adapter.

Former Member
0 Kudos

Hi,

You would also need to make sure that the xml declaration of the payload has the same encoding 'iso-8859-1'

Refer note 856597 for more details on this.

Regards,

Smitha.

Former Member
0 Kudos

Thanks. I read the note many times but I didnt see that I forgot to add

<?xml version="1.0" encoding="ISO-8859-1"?>

before the envelop declaration. My bad.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Have you changed the encoding scheme at the receiver soap adapter?

By default the soap adater has a UTF-8 encoding.

Regards,

Smitha.

Former Member
0 Kudos

I added the parameter XMBWS.XMLEncoding iso-8859-1 for the soap module but my payload is still encoded as UTF-8. Do I need to add something to the file i'm sending saying to use iso-8859-1?

Thanks

agasthuri_doss
Active Contributor
0 Kudos

Hi,

This might also cause due to time out, Check this Note - Note : 705013.

This might help you

Regards

Agasthuri Doss