Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SOAP framework accessing XML element attributes

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
1,008

Hi,

I have looked around and spent considerable time in the ABAP debugger without cracking this. Hope someone here can help me.

I have generated an ABAP SOAP proxy for consuming a web service. All works well.

This web service uses a generic method to retrieve data for any entity. To achieve this the response has the data stored in the XML element attributes rather than in the element content.

So instead of seeing something like this....


<Object>

  <Name>Fred</Name>

  <Address>1 Plane Street</Address>

  <City>Sydney</City>

</Object>

...I need to handle something like this...


<Object name="Fred" address="1 Plane Street" city="Sydney">

</Object>

I can't figure out how to do this from the generated proxy class. Has anyone come across this before?

Thanks

Graham Robbo

1 ACCEPTED SOLUTION
Read only

js2
Product and Topic Expert
Product and Topic Expert
0 Likes
845

So the web service can be called and returns the correct data - you just can't access the top-level nodes attributes?

If that is the case you could get them via the PAYLOAD protocol (IF_WS_PAYLOAD).

i.e.

payload_handler = cl_proxy_access=>get_payload_handler( 

proxy_name = 'CO_...' 

proxy_method = 'EXECUTE_SYNCHRONOUS' ).

Then use "GET_PAYLOAD_FROM_RESPONSE_DATA()".

* Show payload for test purposes

lo_pointer = lo_payload->get_xml_pointer( ).

cl_proxy_service=>show_xml_document( lo_pointer-> ).

Querying the Payload - ABAP Web Services - SAP Library??

4 REPLIES 4
Read only

js2
Product and Topic Expert
Product and Topic Expert
0 Likes
846

So the web service can be called and returns the correct data - you just can't access the top-level nodes attributes?

If that is the case you could get them via the PAYLOAD protocol (IF_WS_PAYLOAD).

i.e.

payload_handler = cl_proxy_access=>get_payload_handler( 

proxy_name = 'CO_...' 

proxy_method = 'EXECUTE_SYNCHRONOUS' ).

Then use "GET_PAYLOAD_FROM_RESPONSE_DATA()".

* Show payload for test purposes

lo_pointer = lo_payload->get_xml_pointer( ).

cl_proxy_service=>show_xml_document( lo_pointer-> ).

Querying the Payload - ABAP Web Services - SAP Library??

Read only

js2
Product and Topic Expert
Product and Topic Expert
0 Likes
845

What's wrong with this editor - the formatting of my response above is all over the place - sorry about that.

Read only

0 Likes
845

Thanks mate - that link to the docu really helped. Not sure why I couldn't find that but you have saved my weekend.

Cheers

Graham Robbo

Read only

0 Likes
845

That just shows you are doing it right.