Closed carnau closed 7 years ago
Can you share the content of bin/demo-server.php
?
Do not forget to add the header handler as :
use GoetasWebservices\SoapServices\SoapClient\Arguments\Headers\Handler\HeaderHandler;
$headerHandler = new HeaderHandler();
$serializer = SoapContainerBuilder::createSerializerBuilderFromContainer($container, function($h) use($headerHandler){
$h->registerSubscribingHandler($headerHandler);
})->build();
An example is available in the test suite as https://github.com/goetas-webservices/soap-client/blob/master/tests/Client/ClientRequestResponsesTest.php#L66
Sure, I added the lambda function with the HeaderHandler but got the same error.
PHP Fatal error: Uncaught ReflectionException: Class GoetasWebservices\SoapServices\SoapEnvelope\Headers does not exist in /srv/host/gitlab/carnau/soap-client-demo/vendor/jms/metadata/src/Metadata/MetadataFactory.php:167
in the generated YAML metadata, do you have some reference to the stringGoetasWebservices\SoapServices\SoapEnvelope\Headers
?
Yes I do, for example in the file SoapEnvelope.Headers.UpdateRatesInput.yml.
Example\ExampleBundle\Soap\HotelServices\SoapEnvelope\Headers\UpdateRatesInput:
xml_namespaces:
SOAP: 'http://schemas.xmlsoap.org/soap/envelope/'
properties:
security:
expose: true
access_type: public_method
accessor:
getter: getSecurity
setter: setSecurity
xml_element:
namespace: 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
serialized_name: Security
type: 'GoetasWebservices\SoapServices\SoapEnvelope\Headers<''Example\ExampleBundle\Soap\Security\Secext\Security''>
after looking a bit, this feature looks to be not fully implemented. at the moment I'm already working on it (see https://github.com/goetas-webservices/soap-client/pull/6) and i guess should be available soon.
Nice to hear this, I will check it. Many thanks.
re opening to keep track if it
the feature to be implemented looks to be pretty trivial.
if you just add
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\XmlDeserializationVisitor;
public static function getSubscribingMethods()
{
return array(
array( // this was already here
'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
'format' => 'xml',
'type' => HeaderPlaceholder::class,
'method' => 'serializeHeader'
),
array( // add this
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
'format' => 'xml',
'type' => 'GoetasWebservices\SoapServices\SoapEnvelope\Headers',
'method' => 'deserializeHeaders'
),
);
}
public function deserializeHeaders(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data, array $type, DeserializationContext $context)
{
$newType = [
'name' => $type['params'][0],
'params' => []
];
return $context->getNavigator()->accept($data, $newType, $context);
}
to soap-client/src/Arguments/Headers/Handler/HeaderHandler.php
should already work
Nice, seems it's working now. Many thanks.
:smile:
Hello,
I'm trying to use the demo with a custom wsdl, but got error when deserializing the OTA_HotelAvailRQ message. Seems that it's not handling the soap headers as expected. Can you give me some thoughts on what is happening? Thank you.
I attach wsdl and xml message.
wsdl.tar.gz
OTA_HotelAvailRQ.txt
Code executed:
$xml = file_get_contents(__DIR__ . '/OTA_HotelAvailRQ.xml');
$test = $serializer->deserialize($xml, ReadRoomTypeCodesInput::class, 'xml');
CLI Response ` carnau@lenovo:/srv/host/gitlab/carnau/soap-client-demo$ php bin/demo-server.php PHP Fatal error: Uncaught ReflectionException: Class GoetasWebservices\SoapServices\SoapEnvelope\Headers does not exist in /srv/host/gitlab/carnau/soap-client-demo/vendor/jms/metadata/src/Metadata/MetadataFactory.php:167 Stack trace:
0 /srv/host/gitlab/carnau/soap-client-demo/vendor/jms/metadata/src/Metadata/MetadataFactory.php(167): ReflectionClass->__construct('GoetasWebservic...')
1 /srv/host/gitlab/carnau/soap-client-demo/vendor/jms/metadata/src/Metadata/MetadataFactory.php(72): Metadata\MetadataFactory->getClassHierarchy('GoetasWebservic...')
`