cancel
Showing results for 
Search instead for 
Did you mean: 

while consuming a .NET web service, where one of the parameters is an array(string), how would one construct a SOAP request in SAP

Former Member
0 Kudos

Hi,

I have one .NET web service(deveoped by me) and I have asked my vendor to consume that using ABAP and as one of the parameters is declared as an array, he says it cannot be consumed.

Does any one has any idea on how to consume such a web service in SAP>

Thanks

Sri

Accepted Solutions (0)

Answers (1)

Answers (1)

matt
Active Contributor
0 Kudos

In SAP, the consumer is generated from the WSDL. It creates proxy classes and types automatically, which are then used in the program. It is at least one level of abstraction away from constructing SOAP requests.

However, it is possible to process arrays/tables. I've written a service in SAP that is consumed using XML like this:

<TABLE_OF_DATA>

  <item>

    <field1>item of data</field1>

    <field2>another item</field2>

  </item>

<item>

   <field1>more data</field1>

   <field2>and more</field2>

</item>

</TABLE_OF_DATA>

Former Member
0 Kudos

Hi Matthew,

Thanks for your quick reply. I am aware that SAP / ABAP generates the proxy classes but according to my friend they can only construct a table but not a complex(array) XML string.

My request is almost the same

<items>

   <item1>

     <itemno>

     <itemname>

     <itemdesc>

  </item1>

<item2>

     <itemno>

     <itemname>

     <itemdesc>

</item2>

</items>

May I know how can you construct this request?I would advise them accordingly.I dont know anything in ABAP but I am just posting here on his behalf

Thanks once again

Sri

matt
Active Contributor
0 Kudos

The thing is - you supply them with a WSDL, they generate the proxy. And that's it.

The WSDL defines the type as:

- <xsd:simpleType name="numeric5">

- <xsd:restriction base="xsd:string">

<xsd:maxLength value="5" />

<xsd:pattern value="\d*" />

</xsd:restriction>

</xsd:simpleType>

-      <xsd:simpleType name="char9">

-      <xsd:restriction base="xsd:string">

         <xsd:maxLength value="9" />

</xsd:restriction>

</xsd:simpleType>

<xsd:complexType name="SAP_STUFF">

   <xsd:sequence>

    <xsd:element name="FIELD1" type="tns:char9" />

    <xsd:element name="FIELD2" type="tns:numeric5" />

   </xsd:sequence>

  </xsd:complexType>

- <xsd:complexType name="TABLE_OF_SAP_STUFF">

- <xsd:sequence>

<xsd:element name="item" type="tns:SAP_STUFF" minOccurs="0" maxOccurs="unbounded" />

</xsd:sequence>

</xsd:complexType>


On the ABAP side, the type to fill this structure is automatically generated from the WSDL.

Former Member
0 Kudos

Hi Matthew,

That's how it should be and I believe that's how it is but they claim that if the input parameter is declared as string[] items in .net they say that it cannot be handled and the data at their side is stored in tables and they are not in a position to pass the whole table as string

Please advise

Thanks

Sri.

matt
Active Contributor
0 Kudos

That may well be the case - SAP can be a bit awkward with strings. The solution is to use fixed character instead.

Former Member
0 Kudos

But the limitation is as such that the request may vary and cannot use the fixed character length string.. any other suggestions / advises?

matt
Active Contributor
0 Kudos

Simple

<xsd:simpleType name="numeric3">

  <xsd:restriction base="xsd:string">

    <xsd:maxLength value="3" />

</xsd:restriction>

</xsd:simpleType>

<xsd:simpleType name="char255">

  <xsd:restriction base="xsd:string">

    <xsd:maxLength value="255" />

    <xsd:pattern value="\d*" />

  </xsd:restriction>

</xsd:simpleType>

<xsd:complexType name="BIT_OF_A_STRING">

  <xsd:sequence>

    <xsd:element name="LENGTH" type="tns:numeric3" />

    <xsd:element name="FIELD2" type="tns:char255" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="TABLIZED_STRING">

  <xsd:sequence>

    <xsd:element name="item" type="tns:BIT_OF_A_STRING" minOccurs="0" maxOccurs="unbounded" />

  </xsd:sequence>

</xsd:complexType>

Break your string up into pieces of max length of 255 (or whatever length you like). Build the pieces into a table, with each record holding the length of the piece and the piece itself.

So, if you had a max length of 10, then "this is the string to be transmitted" would be

10,"this is st"

10,"ring to be"

10," transmitt"

2, "ed"

At the other end, the ABAP developer has to reconstruct the table into a string.