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

Calling a webservice with complex type

Former Member
0 Likes
947

Hi,

I have the following question. In .NET I created a webservice which generates an xml file.

[Example]

<Item>

<Code>string1</Code>

<Answer>string2</Answer>

</Item>

<Item>

<Code>string3</Code>

<Answer>string4</Answer>

</Item>

[Example]

The xml contains 20000 entries.

I created an ABAP on the WAS 6.20 to call the webservice. BTW: I am able to connect to a webservice which delivers simple types string etc.

In that ABAP I created an internal table (no header) based on a Structure defined in the dictionary. Which matches the xml file names.

The call and Process are fine. I even get entries in the internal table. 20000 to be exact (So that matches my webservice) However there are no values.

Has anybody here have experience with complex types and the WAS 6.20

grtz Jeroen

If you would like some code then I'll post that next time.

6 REPLIES 6
Read only

Former Member
0 Likes
717

Hi Jeroen,

I just wrote a program to parse XML but mine was just to read XML from application server.

But anyway, first thing you need to make sure that you are getting the XML string in your ABAP program.

Further you need to use XML library interfaces to parse it.

Can you please post the code ?

May be we can help after that!!

Thanks,

Ram

Read only

athavanraja
Active Contributor
0 Likes
717

Make sure that the XML element name representing the internaltable field name is in ALL UPPERCASE .

check out the following weblog where i have converted XML into ABAP ITAB using CALL TRANSFORMATION.

/people/durairaj.athavanraja/blog/2004/09/20/consuming-web-service-from-abap

if its not clear do get back, i will try to post a more simple example.

Regards

Raja

Read only

0 Likes
717

Hi Raja,

I tried uppercasing but unfortunately that didn't help. I still have the same problem. Itab is filled with record but there is no data.

I post the complete code (I did strip all the error handling because that's not the problem) below and a piece of the xml.

The table ZORM_ABC_VALUES contains the following fields:

CUSTOMERCODE CHAR25

CONTROLGROUP CHAR25

DATEMODIFIED CHAR25

Constants: cServerDestination TYPE char64

VALUE '192.168.102.17',

cServerPort TYPE char64

VALUE '80',

cWebServicePage TYPE char64

VALUE '/ABCUpdate/ABCUpdater.asmx',

cWebServiceMethod1 TYPE string

VALUE 'GetList',

cNsVal type string

value 'http://tempuri.org/'.

data: ABCList type standard table of ZORM_ABC_VALUES.

PERFORM CallService.

FORM CallService.

DATA: osoap TYPE REF TO CSoapDocument.

DATA: isoap TYPE REF TO ISoapSerialize.

DATA: otransp TYPE REF TO CSoapTransportHttp.

DATA: oFault TYPE REF TO CSoapFault.

DATA: exTransport TYPE REF TO CSoapExceptionTransport.

DATA: exFault TYPE REF TO CSoapExceptionFault.

DATA: exDocfmt TYPE REF TO CSoapExceptionDocumentFormat.

DATA: exUsage TYPE REF TO CSoapExceptionUsage.

DATA: exResource TYPE REF TO CSoapExceptionResource.

DATA: exInternal TYPE REF TO CSoapExceptionInternal.

DATA: soapurl TYPE string.

DATA: soapact TYPE string.

DATA: exText TYPE string.

DATA: dref TYPE REF TO data.

CREATE OBJECT osoap.

CALL METHOD osoap->set_method

EXPORTING

nsprefix = ''

nsvalue = cNsVal

name = cWebServiceMethod1.

GET REFERENCE OF ABCList INTO dref.

CALL METHOD osoap->add_parameter

EXPORTING

direction = CSoapConstants=>ic_param_out

name = 'GetListResult'

value = dref.

CALL METHOD osoap->set_tag_name_format

EXPORTING format = CSoapConstants=>ic_tagfmt_mixcase.

isoap = osoap.

CALL METHOD CSoapTransport=>new_http_transport

IMPORTING transport = otransp.

CONCATENATE 'http://' cserverdestination ':' cserverport cwebservicepage INTO soapurl.

CALL METHOD otransp->set_destination_by_url

EXPORTING url = soapurl.

CONCATENATE cNsVal cWebServiceMethod1 INTO soapact.

CALL METHOD otransp->set_soapaction

EXPORTING soapaction = soapact.

CALL METHOD otransp->set_payload

EXPORTING payload = isoap.

CALL METHOD otransp->request_response.

CALL METHOD otransp->close.

ENDFORM.

<---XML-->

<?xml version="1.0" encoding="utf-8"?>

<ArrayOfABCList xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">

<ABCList>

<CUSTOMERCODE>1.10751986</CUSTOMERCODE>

<CONTROLGROUP>B</CONTROLGROUP>

<DATEMODIFIED>11/06/2005 03:57:22</DATEMODIFIED>

</ABCList>

<ABCList>

<CUSTOMERCODE>1.10923926</CUSTOMERCODE>

<CONTROLGROUP>B</CONTROLGROUP>

<DATEMODIFIED>11/06/2005 03:57:22</DATEMODIFIED>

</ABCList>

</ArrayOfABCList>

Message was edited by: Jeroen Bijvank

>wrong xml version

Read only

0 Likes
717

i havent tried this method, if you had looked at the weblog reference i am using http_client and Call Transformation to do this kind of job.

try chaing

CUSTOMERCODE CHAR25

CONTROLGROUP CHAR25

DATEMODIFIED CHAR25

to type string and see what happens?

Which version of SAP you are using, if its => WAS6.2 then there are few very useful weblogs look at the weblogs by Thomas Jung.

Regards

Raja

Read only

0 Likes
717

Hi Raja,

I have looked at your weblog and I came to that same conclusion.

Changing to string doesn't help.

As I mentioned in my first post it's a WAS 6.20.

The webservice is from a .NET machine. I heard from some people that there are some problems when SAP consumes .NET webservices. Maybe somebody can confirm this?

with kind regards,

Jeroen Bijvank

Read only

0 Likes
717

Ok tnx for all the replies.

I solved the problem.

I changed the following:

  • CALL METHOD osoap->set_tag_name_format

  • EXPORTING format = CSoapConstants=>ic_tagfmt_mixcase.

to

CALL METHOD osoap->set_tag_name_format

EXPORTING format = CSoapConstants=>ic_tagfmt_default.

And now the structure is filled with data.

Tnx for taking the time to reply.

grtz Jeroen