I’m having trouble setting an element-value in my soap request with php5.
I’m using php’s native SoapClient.
I’ve mapped the request-object from a webservice to a proxy-class with classmaps.
The request-object should be tranfered to the webservice like this:
<soapElement attributename="attribValue">elemValue</soapElement>
My proxy-class look like this:
class someRequest {
public $attributename;
public $value; //wild guess
}
I initialize the class and set the variables like this:
$someReq = new someRequest();
$someReq->attributename = 'attribValue';
$someReq->value = 'elemValue';
When I call the webservice with my request:
$client->someOperation($someReq);
my request will look like this:
<soapElement attributename="attribValue"/>
As you can see the soapElement value is empty.
How can I set the value of soapElement using my proxy-class?
If someone else is wondering about this, I’ve found the answer now:
The variable name representing the element-value need to be named $_.
The following code will work:
and
The request will then look like this: