cancel
Showing results for 
Search instead for 
Did you mean: 

& in the input structure

Former Member
0 Kudos

Hi All,

I am working on the SOAP to PROXY synchronous scenario. We have exposed the interface as web service and executing the WSDL using Altova XMLSpy. The problem we are facing is that XML is unable to recognize "&".

For Ex - say one of the field Street is populated with:

<Street>N VAN DIEN AVE & LINWOOD</Street>

This request is not processed and gettin the error:

The .xml is not well formed.

character ' ' is grammatically unexpected.

Could someone please tell me how to include the & in an XML element and how to get this request processed successfully.

Thanks in advance.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi ,

As per my understanding, you are sending a soap request. It's entering the XI but instead of adapter engine your using proxy at receiver side. Please correct me if i am wrong. I believe soap request must be entering the integration engine and getting failed in message transform pipeline step. Is it so?

So, I donot think you reuired to make any changes at proxy level, but instead of it you can make proper changes at message transform step ie message mapping level. As per my previous reply, please follow the steps at mapping level and then proper message transformation will happen.

Please let me know if you get proper solution for this.

Regards,

Nutan

Former Member
0 Kudos

Hi,

You need to convert the & into <&amp;> by using java mapping for special characters. Please follow the link below.

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/9420 [original link is broken] [original link is broken] [original link is broken]

and similar post:

It will resolve your issue.

Regards,

Nutan

stefan_grube
Active Contributor
0 Kudos

> Could someone please tell me how to include the & in an XML element and how to get this request processed successfully.

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

-> & amp ;

without spaces

Former Member
0 Kudos

Hi ,

The XML cannot contain certain characters in payload.. we chould convert them into proper format..

So u can use this small function to encode the input to proper format..

private String encodeString(String pstrText) {

pstrText = pstrText.replaceAll("&","\&amp;");

pstrText = pstrText.replaceAll(">","\&gt;");

pstrText = pstrText.replaceAll("<","\&lt;");

pstrText = pstrText.replaceAll("'",\"'");

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

return pstrText;

}

Babu

Edited by: hlbabu123 on Apr 20, 2010 12:31 PM

Former Member
0 Kudos

Hi

Thanks for your instant reply.

You mean to say that we need to handle this in our proxy code. Right?

Is there any way we can restrict these characters on the adapter level or trying some encoding rule in the WSDL itself?

stefan_grube
Active Contributor
0 Kudos

> You mean to say that we need to handle this in our proxy code. Right?

No, always fix the issue at sender side. Put the correct value in the XMLSpy test string.

> Is there any way we can restrict these characters on the adapter level or trying some encoding rule in the WSDL itself?

XML is a standard, the sender must provide the message according to the standard, there is nothing you have to mention additionally.

Former Member
0 Kudos

Hi ,

The XML cannot contain certain characters in payload.. we chould convert them into proper format..

So u can use this small function to encode the input to proper format..


        private String encodeString(String pstrText) {
          pstrText = pstrText.replaceAll("&","&amp;");
          pstrText = pstrText.replaceAll(">","&gt;");
          pstrText = pstrText.replaceAll("<","&lt;");
          pstrText = pstrText.replaceAll("'","'");
          pstrText = pstrText.replaceAll("\"","&quot;");        
          return pstrText;
      }

The formatting makes the above code displaying in different format..

So, the replaceAll values in order is...2nd parameter in quotes

& amp;

& gt;

& lt;

& #39;

& quot;

Please remove the space after & before amp....

Babu

Former Member
0 Kudos

Hi sriparna,

You mean to say that we need to handle this in our proxy code. Right?

No. It will leads to error while execution as ur target payload will be wrong XML format.

Is there any way we can restrict these characters on the adapter level or trying some encoding rule in the WSDL itself?

Yes. U try to avoid the wrong format of the XML payload from the source itself....

Check the source payload once if it is in correct format or not.

From moni get the payload and save it as .xml and open it... u will get the error if any....

Or in mappin u can write the above method and parse the payload to it now... it will convert automatically to correct format..

Babu

Former Member
0 Kudos

Hi Stefan,

Can you please explain in detail.

In our case there is soap adapter on the sender side. Once the input fields are populated, the web service is invoked and proxy is called.

How can we restrict & in the soap adapter (sender side) itself.

stefan_grube
Active Contributor
0 Kudos

> Can you please explain in detail.

There is nothing to explain in detail.

The sender has to provide a valid XML.

If the XML is not valid, the sender application has to be fixed.