Merge remote-tracking branch 'origin/request_headers'
This commit is contained in:
37
ServiceDefinition/Dumper/Wsdl.php
Normal file
37
ServiceDefinition/Dumper/Wsdl.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the BeSimpleSoapBundle.
|
||||
*
|
||||
* (c) Christian Kerl <christian-kerl@web.de>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
|
||||
|
||||
use Zend\Soap\Wsdl as BaseWsdl;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class Wsdl extends BaseWsdl
|
||||
{
|
||||
public function addBindingOperationHeader(\DOMElement $bindingOperation, array $headers, array $baseBinding)
|
||||
{
|
||||
foreach ($headers as $header) {
|
||||
$inputNode = $bindingOperation->getElementsByTagName('input')->item(0);
|
||||
|
||||
$headerNode = $this->toDomDocument()->createElement('soap:header');
|
||||
$headerNode->setAttribute('part', $header);
|
||||
|
||||
foreach ($baseBinding as $name => $value) {
|
||||
$headerNode->setAttribute($name, $value);
|
||||
}
|
||||
|
||||
$inputNode->appendChild($headerNode);
|
||||
}
|
||||
|
||||
return $bindingOperation;
|
||||
}
|
||||
}
|
@ -17,8 +17,6 @@ use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
|
||||
use BeSimple\SoapBundle\Util\Assert;
|
||||
use BeSimple\SoapBundle\Util\QName;
|
||||
|
||||
use Zend\Soap\Wsdl;
|
||||
|
||||
/**
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
@ -49,8 +47,13 @@ class WsdlDumper implements DumperInterface
|
||||
$this->wsdl->addService($this->getServiceName(), $this->getPortName(), $this->qualify($this->getBindingName()), $endpoint);
|
||||
|
||||
foreach ($definition->getMethods() as $method) {
|
||||
$requestParts = array();
|
||||
$responseParts = array();
|
||||
$requestHeaderParts =
|
||||
$requestParts =
|
||||
$responseParts = array();
|
||||
|
||||
foreach ($method->getHeaders() as $header) {
|
||||
$requestHeaderParts[$header->getName()] = $this->wsdl->getType($header->getType()->getPhpType());
|
||||
}
|
||||
|
||||
foreach ($method->getArguments() as $argument) {
|
||||
$requestParts[$argument->getName()] = $this->wsdl->getType($argument->getType()->getPhpType());
|
||||
@ -60,26 +63,38 @@ class WsdlDumper implements DumperInterface
|
||||
$responseParts['return'] = $this->wsdl->getType($method->getReturn()->getPhpType());
|
||||
}
|
||||
|
||||
if (!empty($requestHeaderParts)) {
|
||||
$this->wsdl->addMessage($this->getRequestHeaderMessageName($method), $requestHeaderParts);
|
||||
}
|
||||
$this->wsdl->addMessage($this->getRequestMessageName($method), $requestParts);
|
||||
$this->wsdl->addMessage($this->getResponseMessageName($method), $responseParts);
|
||||
|
||||
$portOperation = $this->wsdl->addPortOperation($port, $method->getName(), $this->qualify($this->getRequestMessageName($method)), $this->qualify($this->getResponseMessageName($method)));
|
||||
$portOperation = $this->wsdl->addPortOperation(
|
||||
$port,
|
||||
$method->getName(),
|
||||
$this->qualify($this->getRequestMessageName($method)),
|
||||
$this->qualify($this->getResponseMessageName($method))
|
||||
);
|
||||
$portOperation->setAttribute('parameterOrder', implode(' ', array_keys($requestParts)));
|
||||
|
||||
$bindingInput = array(
|
||||
'parts' => implode(' ', array_keys($requestParts)),
|
||||
'use' => 'literal',
|
||||
'namespace' => $definition->getNamespace(),
|
||||
'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
|
||||
);
|
||||
$bindingOutput = array(
|
||||
'parts' => implode(' ', array_keys($responseParts)),
|
||||
$baseBinding = array(
|
||||
'use' => 'literal',
|
||||
'namespace' => $definition->getNamespace(),
|
||||
'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/',
|
||||
);
|
||||
|
||||
$bindingOperation = $this->wsdl->addBindingOperation($binding, $method->getName(), $bindingInput, $bindingOutput);
|
||||
$bindingOperation = $this->wsdl->addBindingOperation(
|
||||
$binding,
|
||||
$method->getName(),
|
||||
array_merge(array('parts' => implode(' ', array_keys($requestParts))), $baseBinding),
|
||||
array_merge(array('parts' => implode(' ', array_keys($responseParts))), $baseBinding)
|
||||
);
|
||||
$bindingOperation = $this->wsdl->addBindingOperationHeader(
|
||||
$bindingOperation,
|
||||
array_keys($requestHeaderParts),
|
||||
array_merge(array('message' => $this->qualify($this->getRequestHeaderMessageName($method))), $baseBinding)
|
||||
);
|
||||
|
||||
$this->wsdl->addSoapOperation($bindingOperation, $this->getSoapOperationName($method));
|
||||
}
|
||||
|
||||
@ -126,6 +141,11 @@ class WsdlDumper implements DumperInterface
|
||||
return $this->definition->getName().'Service';
|
||||
}
|
||||
|
||||
protected function getRequestHeaderMessageName(Method $method)
|
||||
{
|
||||
return $method->getName().'Header';
|
||||
}
|
||||
|
||||
protected function getRequestMessageName(Method $method)
|
||||
{
|
||||
return $method->getName().'Request';
|
||||
|
@ -16,7 +16,7 @@ use BeSimple\SoapBundle\ServiceDefinition\Strategy\ComplexType;
|
||||
use BeSimple\SoapBundle\Util\String;
|
||||
|
||||
use Zend\Soap\Exception;
|
||||
use Zend\Soap\Wsdl;
|
||||
use Zend\Soap\Wsdl as BaseWsdl;
|
||||
use Zend\Soap\Wsdl\Strategy;
|
||||
use Zend\Soap\Wsdl\Strategy\ArrayOfTypeSequence;
|
||||
|
||||
@ -46,7 +46,7 @@ class WsdlTypeStrategy implements Strategy
|
||||
*
|
||||
* @param \Zend\Soap\Wsdl $context
|
||||
*/
|
||||
public function setContext(Wsdl $context)
|
||||
public function setContext(BaseWsdl $context)
|
||||
{
|
||||
$this->context = $context;
|
||||
|
||||
|
Reference in New Issue
Block a user