cancel
Showing results for 
Search instead for 
Did you mean: 

Passing XML string to WebService

Former Member
0 Kudos

Hi,

I am tring to call a .net WS from ABAP.

I know how to call a WS when i have to pass normal parameters. But my problem is the WS service is expecting a string as input which should be valid XML. The XSD is not simple it contains complex structure. That is somethign like header data and under that we have address data nodes which will occur multimple time and phone data nodes which will also occur multiple times.

I dont know how to create this input string inside ABAP.

Any help please.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

There are ABAP classes and interfaces to work with XML data:

cl_ixml -> Allows to create XML documents

if_ixml_document -> Interface to work with XML documents

if_ixml_element -> Interface to work with an element within a XML doc

Main steps:

1. Get a reference to IF_IXML

l_xml = cl_ixml=>create( ).

2. Create a XML document

l_xml_doc = l_xml->create_document( ).

3a. Transform ABAP structure into XML with function module SDIXML_DATA_TO_DOM (Best option)

l_xml_doc = l_xml->create_document( ).

NOTE: You can create ABAP structures with fields and other structures to get the desired XML

3b. Create XML dinamically by creating elements and adding these elements to the XML document

l_root = l_xml_doc->create_element( name = 'root' ).

l_child = l_xml_doc->create_element( name = 'child' ).

l_root->append_child( new_child = l_child ).

4. Use function module SDIXML_DOM_TO_XML to get the desired string. This FM returns a XSTRING and a table with the XML. You can convert the XSTRING to STRING or use the table.

I hope this can be useful,

Best regards,

Jorge Linares

Answers (3)

Answers (3)

Former Member
0 Kudos

Yes Jorge you are correct. That is a generic WS.

Anyway finally i created my XML stirng using the following blog...

/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach

Former Member
0 Kudos

Hi Daniel,

I agree with you.

However, I don't know what this .NET WS is doing. Maybe it cannot be re-designed or it really needs an XML as a parameter.

Regards,

Jorge

Former Member
0 Kudos

Hi,

Wouldn't it be easier to wrap the WS with a simpler one, which uses simple input parameters? Who will ever call a WS wich uses a XML File as input? WS call should be as simple as possible, or not?

Regards,

Daniel