Hello,
I have created a Web Service client application that is going to send SOAP messages in a remote service running on a websphere server outside of the iSeries.
To create this application, firstly, I used the WSDL2Ws tool in order to auto-generate the service ?stub? methods (based on a provided .wsdl file).
The stubs are written in RPG.
After that, I coded an RPGle program (that uses the auto-generated code) in order to retrieve some data from the database and send them to the remote web service.
Auto Generated code
The remote web service has an operation that is called addCustomer.
This operation requires as input the following ?Customer_t? structure (as it is auto-generated by the WSDL2Ws tool):
my custom code
In my RPG program, I populate the Customer_t variable (with name WsInput) as following:
problem description
My problem is that the XML message that is sent in the remote application (you can see below the message structure)
contains all the values that are set in my program except for the address details.
i guess that it is happening because the address details are defined as array, but I do not know how to fix it.
Can anyone help me with that?
Thank you in advance
WSDL file (.xsd file actually)
//Xml message that arrives to websphere.
I have created a Web Service client application that is going to send SOAP messages in a remote service running on a websphere server outside of the iSeries.
To create this application, firstly, I used the WSDL2Ws tool in order to auto-generate the service ?stub? methods (based on a provided .wsdl file).
The stubs are written in RPG.
After that, I coded an RPGle program (that uses the auto-generated code) in order to retrieve some data from the database and send them to the remote web service.
Auto Generated code
The remote web service has an operation that is called addCustomer.
This operation requires as input the following ?Customer_t? structure (as it is auto-generated by the WSDL2Ws tool):
Code:
D Customer_t ds qualified template D isNil_Customer_t 1n D name likeds(xsd_String) D contactDetails likeds(contact_details_t) D addresses likeds(address_Array_t) *The above DS requires some other DSs (see below). D Contact_details_t ds qualified template D isNil_contact_Details_t 1n D phone likeds(xsd_String) D email likeds(xsd_String) D address_Array_t ds qualified template D isNil_address_array_t 1n D array likeds(address_t) dim(15) D size 10i 0 D type 10i 0 D address_t ds qualified template D isNil_address_t 1n D city likeds(xsd_String) D street likeds(xsd_String) D number likeds(xsd_long)
my custom code
In my RPG program, I populate the Customer_t variable (with name WsInput) as following:
Code:
d WsStub ds likeds(This_t) d WsInput ds likeds(Customer_t) d WsOutput ds likeds(xsd_string) c Eval WsInput.name.value = ?john doe? c Eval WsInput.contactDetails.phone.value = ?123456789? c Eval WsInput.contactDetails.email.value = ?test@test.com? c Eval WsInput.addresses.array(1).city.value = ?city1? c Eval WsInput.addresses.array(1).street.value = ?street1? c Eval WsInput.addresses.array(1).number.value = 111 c Eval WsInput.addresses.array(2).city.value = ?city2? c Eval WsInput.addresses.array(2).street.value = ?street2? c Eval WsInput.addresses.array(2).number.value = 222 //After that I try to post the request like this: if stub_create_CustomerWS(WsStub); // Invoke the Web service operation. if stub_op_addCustomer0(WsStub:WsInput:wsOutput); outputText = wsOutput.value; else; outputText = WsStub.excString; endif; // Destroy Web service stubs. stub_destroy_CustomerWS(WsStub); endif;
problem description
My problem is that the XML message that is sent in the remote application (you can see below the message structure)
contains all the values that are set in my program except for the address details.
i guess that it is happening because the address details are defined as array, but I do not know how to fix it.
Can anyone help me with that?
Thank you in advance
WSDL file (.xsd file actually)
HTML Code:
<xs:element name="addCustomer" type="tns:addCustomer"/> <xs:element name="addCustomerResponse" type="tns:addCustomerResponse"/> <xs:complexType name="addCustomer"> <xs:sequence> <xs:element name="customer" type="tns:customerDetails" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="customerDetails"> <xs:sequence> <xs:element name="name" type="xs:string" minOccurs="0"/> <xs:element name="contactDetails" type="tns:contactDetails" minOccurs="0"/> <xs:element name="addresses" type="tns:address" nillable="true" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="contactDetails"> <xs:sequence> <xs:element name="phone" type="xs:string" minOccurs="0"/> <xs:element name="email" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="address"> <xs:sequence> <xs:element name="city" type="xs:string" minOccurs="0"/> <xs:element name="street" type=" xs:string" minOccurs="0"/> <xs:element name="number" type="xs:long" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="addCustomerResponse"> <xs:sequence> <xs:element name="return" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType>
//Xml message that arrives to websphere.
HTML Code:
<ns1:addCustomer xmlns:ns1="http://blablabla.com/"> <customer> <name>john doe</accountNo> <contactdetails> <phone>123456789</phone> <email>test@test.com</email> </contactdetails> </customer> </ns1:addCustomer>
Comment