I am trying to return values the way they are sent into my soap server so they have the same XML structure.
Here is a sample request for multiple policies with various attributes.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="https://customer-soap.example.com/?WSDL">
<soapenv:Header/>
<soapenv:Body>
<wsdl:SendPoliciesRequestInput>
<sesid>someid</sesid>
<!--Optional:-->
<policy product="product1" company="ges1" polizzenNr="pol1" premium="1" expiry="01.01.2000" info="blabla1"/>
<policy product="product2" company="ges2" polizzenNr="pol2" premium="2" expiry="02.01.2000" info="blabla2"/>
</wsdl:SendPoliciesRequestInput>
</soapenv:Body>
</soapenv:Envelope>
In my php code this translates to an object containing a sesid
and an array of policy
elements like this: (print_r($request)
)
stdClass Object
(
[sesid] => someid
[policy] => Array
(
[0] => stdClass Object
(
[product] => product1
[company] => ges1
[Nr] => pol1
[premium] => 1
[expiry] => 01.01.2000
[info] => blabla1
)
[1] => stdClass Object
(
[product] => product2
[company] => ges2
[Nr] => pol2
[premium] => 2
[expiry] => 02.01.2000
[info] => blabla2
)
When trying to return this exact object back to the caller the following code
<php
class Example
{
public function SendPolicies($request)
{
return $request;
}
}
outputs like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="https://customer-soap.example.com/?WSDL">
<soapenv:Header/>
<soapenv:Body>
<wsdl:SendPoliciesRequestOutput>
<sesid>someid</sesid>
<!--Optional:-->
<policy />
</wsdl:SendPoliciesRequestOutput>
</soapenv:Body>
</soapenv:Envelope>
I've tried several approaches including creating SoapVar
but this would only restructure the objects instead of creating an output that is exactly the same as the input.
Every help is much appreciated.