cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with special characters with SOAP Adapter

Former Member
0 Kudos

Hi

We uses SAP XI 3.0 SPS18.

We need to add a SOAP header and for that we implement a adapter module and use the SOAP adapter with the "Don't use SOAP" flag.

The problem is now, that the adapter sends SOAP Messages with wrong special character within the payload.

We have inside an element the following String :

"

The SOAP receiver receives:

<ns1:Description Value="- Pivotant (ou fixe)&lt;BR&gt;- Hauteur réglable&lt;BR&gt;- Angle d&apos;orientation réglable&lt;BR&gt;- Grille de protection métallique&lt;BR&gt;- Ã&#152; env. 40 cm&lt;BR&gt;- 3 vitesses&lt;BR&gt;- Bouton à 4 positions (0-1-2-3)&lt;BR&gt;- Alimentation en courant: 230 V, 50 Hz, 50 W&lt;BR&gt;"

As you see, all special characters are wrong now.

To test the module, I simply reduce the module to the coding below but the same problem.

Any idea ?

Regards,

Gerald

package xi.charset;

import java.io.IOException;

import javax.ejb.CreateException;

import javax.ejb.SessionBean;

import javax.ejb.SessionContext;

import com.sap.aii.af.mp.module.Module;

import com.sap.aii.af.mp.module.ModuleContext;

import com.sap.aii.af.mp.module.ModuleData;

import com.sap.aii.af.mp.module.ModuleException;

import com.sap.aii.af.ra.ms.api.InvalidParamException;

import com.sap.aii.af.ra.ms.api.Message;

import com.sap.aii.af.ra.ms.api.XMLPayload;

/**

  • @ejbHome <{xi.charset.CharsetTesterHome}>

  • @ejbLocal <{xi.charset.CharsetTesterLocal}>

  • @ejbLocalHome <{xi.charset.CharsetTesterLocalHome}>

  • @ejbRemote <{xi.charset.CharsetTester}>

  • @stateless

  • @transactionType Container

*/

public class CharsetTesterBean implements SessionBean, Module {

public void ejbRemove() {

}

public void ejbActivate() {

}

public void ejbPassivate() {

}

public void setSessionContext(SessionContext context) {

myContext = context;

}

private SessionContext myContext;

/**

  • Create Method.

*/

public void ejbCreate() throws CreateException {

// TODO : Implement

}

/* (non-Javadoc)

  • @see com.sap.aii.af.mp.module.Module#process(com.sap.aii.af.mp.module.ModuleContext, com.sap.aii.af.mp.module.ModuleData)

*/

public ModuleData process(ModuleContext moduleContext,ModuleData inputModuleData) throws ModuleException {

Object obj = null;

Message msgIn = null;

XMLPayload xmlPayload = null;

// Extrahieren des Payloads

obj = inputModuleData.getPrincipalData();

msgIn = (Message) obj;

xmlPayload = msgIn.getDocument();

String codepage = xmlPayload.getEncoding();

String text = xmlPayload.getText();

// Set output

try {

try {

xmlPayload.setContent(text.getBytes("utf-8"),"utf-8");

} catch (InvalidParamException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

// xmlPayload.setText(text);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

inputModuleData.setPrincipalData(msgIn);

return inputModuleData;

}

}

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

> xmlPayload.setContent(text.getBytes("utf-8"),"utf-8");

Could you try:

xmlPayload.setContent(text.getBytes());

There should not be a need for setting the code page to UTF-8 as this is the default for a Java program.

Regards

Stefan

Answers (4)

Answers (4)

Former Member
0 Kudos

Works now.

tyvm

Regards

Gerald

Former Member
0 Kudos

Or

Original : Anhängern

Result : Anhängern

Hex : 41 6E 68 C3 A4 6E 67 65 72 6E --> two bytes for ä C3 A4

Regards

Gerald

Former Member
0 Kudos

Hi Stefan

I check the string "für" within the hexeditor.

für is 66 C3 83 C2 BC 72 in hex.

Regards

Gerald

Former Member
0 Kudos

During debugging , the value of xmlPayload.getEncoding(); is "utf-8" and the special chars within String text = xmlPayload.getText(); are right.

Only in the msg object the special chars will be damaged.

stefan_grube
Active Contributor
0 Kudos

Hi Gerald,

the french characters seem correct UTF-8 to me. But they are displayed wrong. Could you confirm this by looking at the file with a hex editor?

If you see 2 bytes for é - that is correct.

If you see 4 bytes for é - that is wrong.

Regards

Stefan