on 08-10-2007 10:23 AM
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)<BR>- Hauteur réglable<BR>- Angle d'orientation réglable<BR>- Grille de protection métallique<BR>- Ø env. 40 cm<BR>- 3 vitesses<BR>- Bouton à 4 positions (0-1-2-3)<BR>- Alimentation en courant: 230 V, 50 Hz, 50 W<BR>"
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;
}
}
> 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Works now.
tyvm
Regards
Gerald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stefan
I check the string "für" within the hexeditor.
für is 66 C3 83 C2 BC 72 in hex.
Regards
Gerald
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.