cancel
Showing results for 
Search instead for 
Did you mean: 

PI SOAP Sender Problem Sending Special Chars < > ' " &

Former Member
0 Kudos

Hello Experts

We are sending Customer Invoice, Accounting and Delivery data IDOCs via XML to a SOAP receiver channel webservice. The data contains some special characters (which should not be present in XML data) as indicated in the following paragraph:

Note: - quote ("), apostrophe ('), ampersand (&), less than (<), greater than (>) are special characters in XML. They should not be present in data per W3.org standards. http://www.w3.org/TR/REC-xml/

The Webservice requires specific strings containing the special characters which exist in some of the Material Descriptions of the Customer Data. This is to be processed by Stored Procedures which cannot process them unless the special characters are formatted as the following examples show:

Examples:

&amp;&apos;     (Translates to &' )

&amp;&quot;     (Translates to &" )

I have created a UDF (shown below the signature) which creates some promising output in the Message Mapping test, however once it reaches the Payload it "converts" and although I have tried various combinations, the closest I have been able to get is shown below. :

&amp;amp;apos;

&amp;&amp;apos;           

It seems that because of the embedded conversion PI performs it may not be possible to send the desired strings as shown in the Example above.

In addition, the required (or ideal) solution should not operate on a field basis but on the entire Payload and would not apply the conversion to the XML tags, but to the data portion of the Payload only.

I am wondering if any of you experts have run in to a similar requirement and what you may have done to solve it? I am hoping that perhaps I may have missed something obvious, such as a character combination that does the trick.

(Some comments I have heard so far is this is better done on the ECC or on the Webservice side, feedback on this would also be valuable, Thanks)

Thanks in advance for your knowledgeable and valued feedback.

Jim

QuestRoi.com

UDF:

String Change_Var = var1;

if (Change_Var.contains("'") || Change_Var.contains("\""))

{

Change_Var = Change_Var.replaceAll("'", "&&apos;");

//Change_Var = Change_Var.replaceAll(" &amp;apos; ", " \\\\&amp;apos; ");

Change_Var = Change_Var.replaceAll("\"", "&&quot;");

//Change_Var = Change_Var.replaceAll(" &amp;quot; ", " \\\\&amp;quot; ");

}

return Change_Var;

Accepted Solutions (0)

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

It is not necessay to escape ' or ".

Only & and < needs to be escaped. SOAP adapter will do this for you.

Do you have any issues in receiver, when you do not change the payload at all?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi John,

What Steve said is true. You can actually verify the content by opening the XML in an editor such as notepad/notepad++, the special characters are not really converted. XML parsers like IE escape the characters when you display it. That said, always use view source (in sxi_monitor) to validate the content of the payload.

Regards,

Mark

Former Member
0 Kudos

Mark

Thanks for your response. I have validated it and show the values above such as

&amp;amp;apos;

&amp;&amp;apos; 

At the webservice end they verify the above values are being sent....

However the challenge remains: to send values such as:

&amp;&apos; 

&amp;&quot;

Thanks

John

Former Member
0 Kudos

Hello Experts:

I have made some changes to try and make this less confusing...

At the Portal end, the way values should be represented is:

&amp;&apos;  ... OR

&amp;&quot;

But when PI delivers the message, the values are represented as:

&amp;&amp;apos;

&amp;&amp;quot;

I understand that they are same XML values but differ in representation. The challenge is that there is SP which uses these values and the PI delivered values are unable to get processed.

Is there a way I might be able to deliver these values as required by the Portal (&amp;&apos; OR &amp;&quot;)?

Thanks

John

markangelo_dihiansan
Active Contributor
0 Kudos

Hi John,

Can you wrap the values it in a CDATA tag and see if it works?

Regards,

Mark

steve_coombes
Participant
0 Kudos

Hello John

Sorry, I misread your original question.

If PI is delivering

     &amp;&amp;apos;


then the text before escaping was


     &&apos;


If you are sending

    

     &'


then the data should be escaped as


     &amp;&apos;


and PI should escape again to


     &amp;amp;&amp;apos;


There is an example of XML escaping on StackOverflow :


http://stackoverflow.com/questions/439298/best-way-to-encode-text-data-for-xml-in-java


You could put that in a UDF and use it on all XML data elements that require escaping. I would expect PI to escape the result correctly.


Kind regards


Steve






steve_coombes
Participant
0 Kudos

Hello John

Doesn't PI escape these characters for you? What is the exact problem that occurs when you send an Idoc containing a special character to the web service?

Kind regards

Steve