I've used the PackageGenerator to generate the classes to connect to a 3rd party SOAP service, but seem to be having issues with the generated XML. Seems to be regarding extended classes. Not sure what I'm doing wrong, or if I should have used some specific options when generating the classes.
What I get in my generated classes is (methods removed for readability):
/**
* This class stands for Post ServiceType
* @subpackage Services
*/
class Post extends AbstractSoapClientBase
{
/**
* Method to call the operation originally named postMessage
* @uses AbstractSoapClientBase::getSoapClient()
* @uses AbstractSoapClientBase::setResult()
* @uses AbstractSoapClientBase::saveLastError()
* @param \EAPI\StructType\PostMessage $parameters
* @return \EAPI\StructType\PostMessageResponse|bool
*/
public function postMessage(\EAPI\StructType\PostMessage $parameters)
{
try {
$this->setResult($resultPostMessage = $this->getSoapClient()->__soapCall('postMessage', [
$parameters,
], [], [], $this->outputHeaders));
return $resultPostMessage;
} catch (SoapFault $soapFault) {
$this->saveLastError(__METHOD__, $soapFault);
return false;
}
}
}
class PostMessage extends AbstractStructBase
{
public function __construct(?string $mainMemberCode = null, ?\EAPI\StructType\ErosMessage $erosMessage = null)
{
$this
->setMainMemberCode($mainMemberCode)
->setErosMessage($erosMessage);
}
}
abstract class ErosMessage extends AbstractStructBase
{
public function __construct(?string $correlationReference = null, ?string $externalReferenceNumber = null, ?string $operator = null, ?string $receivingMemberCode = null, ?string $sendingMemberCode = null, ?string $service = null)
{
$this
->setCorrelationReference($correlationReference)
->setExternalReferenceNumber($externalReferenceNumber)
->setOperator($operator)
->setReceivingMemberCode($receivingMemberCode)
->setSendingMemberCode($sendingMemberCode)
->setService($service);
}
}
class OrderMessage extends ErosMessage
{
public function __construct(?int $originalOrderSequenceNumber = null, ?string $originalOrderReferenceNumber = null, ?string $cardMessage = null, ?string $conventionMessage = null, ?string $deliveryDate = null, ?string $deliveryDetails = null)
{
$this
->setOriginalOrderSequenceNumber($originalOrderSequenceNumber)
->setOriginalOrderReferenceNumber($originalOrderReferenceNumber)
->setCardMessage($cardMessage)
->setConventionMessage($conventionMessage)
->setDeliveryDate($deliveryDate)
->setDeliveryDetails($deliveryDetails);
}
}
My code to create and post a new message to the SOAP service is:
$message = new OrderMessage($originalOrderSequenceNumber, $originalOrderReferenceNumber, $cardMessage, $conventionMessage, $deliveryDate, $deliveryDetails);
$message->setCorrelationReference($correlationReference);
$message->setExternalReferenceNumber($externalReferenceNumber);
$message->setOperator($operator);
$message->setReceivingMemberCode($receivingMemberCode);
$message->setSendingMemberCode($this->mainMemberCode);
$message->setService($this->service);
$params = new PostMessage($this->mainMemberCode, $message);
$post = new Post($this->options);
$post->setLocation($this->wsdl);
$result = $post->postMessage($params);
When retrieving the last request, this results in:
I've used the PackageGenerator to generate the classes to connect to a 3rd party SOAP service, but seem to be having issues with the generated XML. Seems to be regarding extended classes. Not sure what I'm doing wrong, or if I should have used some specific options when generating the classes.
What I get in my generated classes is (methods removed for readability):
My code to create and post a new message to the SOAP service is:
When retrieving the last request, this results in:
However, the vendor specs and wsdl say it should look like this:
I can't figure out why the attributes for the PostMessage class show up in the XML but the attributes for the extended class OrderMessage do not.
I also see the erosMessage in the XML has an xsi:type="v1:orderMessage". Is there something I need to do for that to encode?