$wsdl
! is_string($wsdlClass)
$this->uri === null
is_array($classMap)
is_array($function)
is_string($this->uri)
$uri
$strategy
$uri
Uri\UriFactory::factory($this->uri)
$this->uri
Uri\Uri
$filename
new $this->wsdlClass($serviceName, $uri, $this->strategy, $this->classMap)
$wsdl
null|array
addFunctionToWsdl
handle
$binding
$func
$function->getName()
$function->getName()
$method
$port
$row
$this->uri
$wsdlClass
$args[$param->getName()]
$binding
$func
$method
$port
$row
string
addBinding
addPortType
addSchemaTypeSection
addService
addSoapBinding
$this->reflection->reflectClass($this->class)->getShortName()
Wsdl
$classMap
$class
$serviceName
$strategy
$uri
is_string($function)
Client
! is_resource($context)
$this->getWSDL() === null
$this->getWSDL() === null
$this->soapClient === null
$wsdl === null
is_array($arguments)
is_string($encoding)
array
array
string
string
string
string
$context
$style
$use
(int) $proxyPort
$this->proxyPort
$this->streamContext
$this->style
$this->use
int
int
int
resource
Exception\ExceptionInterface
initSoapClientObject
$class
$result
$type['type_name']
$type['type_name']
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$key
$type['from_xml']
$type['to_xml']
$type['type_name']
$type['type_name']
$class
$options['classmap']
$result
$this->connectionTimeout
$type
$value
$value
$class
$soapClient->__getFunctions()
$soapClient->__getTypes()
$this->soapClient->__getLastRequest()
$this->soapClient->__getLastRequestHeaders()
$this->soapClient->__getLastResponse()
$this->soapClient->__getLastResponseHeaders()
$feature
$this->soapOutputHeaders
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
$cacheWsdl
$classmap
$compression
$connectionTimeout
$features
$keepAlive
$localCert
$location
$login
$passphrase
$password
$proxyHost
$proxyLogin
$proxyPassword
$proxyPort
$soapClient
$sslMethod
$streamContext
$style
$typemap
$uri
$use
$userAgent
$wsdl
(bool) $keepAlive
(int) $compressionOptions
(int) $proxyPort
(string) $userAgent
$this->soapClient !== null
$this->soapClient !== null
$this->soapClient !== null
$this->soapClient !== null
$oneWay
$oneWay
DotNet
$this->curlClient === null
$result
$options
$options
mixed
parent::setOptions($options)
$this->options['login']
$this->options['password']
$value
string
$value
self
$uri->getHost()
$curlClient
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
DotNet
$options
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
Local
$serverResponse !== null
$response === null
$response === null
$class
$fault
$this->class
$xml
$xml
'Exception'
Server
$function === SOAP_FUNCTIONS_ALL
$function === SOAP_FUNCTIONS_ALL
is_array($classmap)
is_array($typeMap)
is_object($object)
is_string($class)
is_string($encoding)
$code
self
self
self
self
$fault
void|string
$displayErrorsOriginalState
bool
$code
handlePhpErrors
$class
$row
$type['type_name']
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$value
$xml
$key
[$this, 'handlePhpErrors']
$type['from_xml']
$type['to_xml']
$type['type_name']
$type['type_name']
$func
$options['classmap']
$row
$type
$value
$xml
null|string|int|bool
$type['type_name']
$this->wsdlCache
$class
$fault
$request
$this->functions[]
$this->functions[]
$feature
$fault->faultcode
$xml
is_string($fault) ? new Exception($fault) : $fault
saveXML
$actor
$caughtException
$class
$classmap
$encoding
$features
$object
$parseHuge
$persistence
$request
$response
$sendErrors
$server
$typemap
$uri
$wsdl
(bool) $flag
(bool) $parseHuge
(bool) $sendErrors
$this->server instanceof SoapServer
is_string($class)
is_string($function)
is_string($request)
null !== $this->actor
null !== $this->class
null !== $this->classmap
null !== $this->encoding
null !== $this->features
null !== $this->object
null !== $this->parseHuge
null !== $this->persistence
null !== $this->sendErrors
null !== $this->soapVersion
null !== $this->typemap
null !== $this->uri
isset($this->class)
isset($this->object)
'Exception' === $class
__toString
assertOnlyOneArgument
assertServiceDelegateHasMethod
$args[0]
$argValue
$delegateArgs[$params[$argName]->getPosition()]
$ret
$inputNode === $this
$inputNode === $this
$this->schema === null
$this->schema === null
is_array($element)
ComplexTypeStrategy
string
$filename
null|array
$attributeValue
$child
$child
$doc
$docCData
$node->firstChild
$subElement
$value
$value
$attributeName
$attributeName
$key
$key
$name
$attributeValue
$child
$child
$doc
$doc
$docCData
$node
$subElement
$type
$value
DOMElement
string
string
string
appendChild
appendChild
appendChild
createElementNS
createElementNS
createElementNS
createTextNode
hasChildNodes
insertBefore
$element['name']
$node->firstChild
$node->namespaceURI
$this->dom->documentElement
$doc
$this->classMap[$type]
$this->includedTypes[$type]
$value
$targetNamespace
$this->strategy
$node->nodeValue
$uri
$classMap
createAttribute
$schema
$this->dom instanceof DOMDocument
$this->wsdl !== null
$types instanceof DOMNode || $types instanceof DOMElement || $types instanceof DOMDocumentFragment
$this->dom
$context
$context
$context
$documentationStrategy
$documentationStrategy
$documentationStrategy
setContext
null|string
$soapTypes[$phpType]
setContext
0
addSequenceType
strpos($arrayType, ':')
setContext
is_string($type)
$strategy
$type
$strategy
new $strategy()
new $strategy()
testNestedObjectArrayResponse
testObjectResponse
$ret
$ret[0]->baz
$baz[0]
$baz[0]
$baz[1]
$baz[1]
$baz[2]
$baz[2]
$ret[0]
$ret[0]
$ret[0]
$b
$baz
$ret
$b
$b
$baz[0]->bar
$baz[0]->foo
$baz[1]->bar
$baz[1]->foo
$baz[2]->bar
$baz[2]->foo
$ret[0]->baz
getenv('TESTS_LAMINAS_SOAP_AUTODISCOVER_ONLINE_SERVER_BASEURI')
LaminasTest_Soap_TestAsset_ComplexTypeB
assertInternalType
assertInternalType
$wsdl->toXML()
["bogus"]
new stdClass()
new stdClass()
assertValidWSDL
bindWsdl
documentNodesTest
testAddFunctionMultiple
testAddFunctionSimple
testAddFunctionSimpleInReturnNameCompabilityMode
testAddFunctionSimpleWithDifferentStyle
testAutoDiscoverConstructorStrategy
testAutoDiscoverConstructorUri
testAutoDiscoverConstructorWsdlClass
testAutoDiscoverConstructorWsdlClassException
testChangeWsdlUriInConstructor
testChangingWsdlUriAfterGenerationIsPossible
testClassMap
testComplexTypesThatAreUsedMultipleTimesAreRecoginzedOnce
testGetDiscoveryStrategy
testGetServiceName
testGetServiceNameException
testGetUriException
testHandle
testNoReturnIsOneWayCallInAddFunction
testNoReturnIsOneWayCallInSetClass
testRecursiveWsdlDependencies
testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArrayComplex
testReturnSameArrayOfObjectsResponseOnDifferentMethodsWhenArraySequence
testSetClass
testSetClassWithDifferentStyles
testSetClassWithResponseReturnPartCompabilityMode
testSetNonStringNonLaminasUriUriThrowsException
testSetServiceName
testSetUriException
testUsingClassWithMethodsWithMultipleDefaultParameterValues
$function
array
array
$msg
empty($documentNamespace)
getAttribute
getAttribute
getAttribute
getAttribute
setMethods
$action
$location
$oneWay
$request
$version
method
method
method
will
with
with
null
expects
expects
expects
$client
$location
$oneWay
$request
$version
setMethods
setMethods
'World'
$wsdlFilename
testAllowNumericZeroAsValueForCacheWsdlOption
testAllowNumericZeroAsValueForCompressionOptions
testCallDirect
testCallDirectWithArgString
testCallInvoke
testGetAndSetUserAgentOption
testGetFunctions
testGetLastRequest
testGetLastResponse
testGetOptions
testGetTypes
testInitSoapClientObjectException
testSetCookieIsDelegatedToSoapClient
testSetInputHeaders
testSetOptions
testSetOptionsWithLaminasConfig
testSetSoapClient
testUserAgentAllowsEmptyString
$element
$element
$element
$typesArray
$typesArray
0
testDelegate
"bogus"
$int
$server
'bogus'
1
465
['Here', 'There', 'Bogus']
['UTF-8']
['UTF-8']
getMessage
getMessage
$wsdlFilename
'bogus'
'bogus'
126
465
5000
SOAP_FUNCTIONS_ALL
$server->mockSoapServer
testAddAllFunctionsSoapConstant
testAddBogusFunctionAsInteger
testAddBogusFunctionsAsArray
testAddBogusFunctionsAsString
testAddFunction
testDebugMode
testDeregisterFaultException
testDisableEntityLoaderAfterException
testEmptyRequest
testEncoding
testErrorHandlingOfSoapServerChangesToThrowingSoapFaultWhenInHandleMode
testFaultWithBogusInput
testFaultWithIntegerFailureCodeDoesNotBreakClassSoapFault
testFaultWithRegisteredException
testFaultWithTextMessage
testFaultWithUnregisteredException
testGetActor
testGetClassmap
testGetFunctions
testGetFunctionsWithClassAttached
testGetFunctionsWithObjectAttached
testGetLastRequest
testGetLastResponse
testGetOptions
testGetOriginalCaughtException
testGetPersistence
testGetReturnResponse
testGetSoapInternalInstance
testGetUri
testGetWsdl
testHandle
testHandlePhpErrors
testHandleUsesProperRequestParameter
testIsRegisteredAsFaultException
testLoadFunctionsIsNotImplemented
testRegisterFaultException
testServerAcceptsLaminasConfigObject
testSetActor
testSetAndGetFeatures
testSetAndGetParseHuge
testSetAndGetWSDLCache
testSetBogusClassWithIntegerName
testSetBogusClassWithUnknownClassName
testSetClass
testSetClassTwiceThrowsException
testSetClassWithArguments
testSetClassWithObject
testSetClassmap
testSetClassmapThrowsExceptionOnBogusArrayParameter
testSetClassmapThrowsExceptionOnBogusStringParameter
testSetObject
testSetObjectThrowsExceptionWithBadInput1
testSetObjectThrowsExceptionWithBadInput2
testSetOptions
testSetOptionsViaSecondConstructorArgument
testSetOptionsWithFeaturesOption
testSetPersistence
testSetReturnResponse
testSetUnknownPersistenceStateThrowsException
testSetUri
testSetWsdl
testSetWsdlViaOptionsArrayIsPossible
testShouldThrowExceptionIfHandledRequestContainsDoctype
testSoapVersion
testValidateUrn
$exception
$response->getMessage()
$response->getMessage()
$row
$server->mockSoapServer->handle[0]
$exception
$row
$row
array
$server->mockSoapServer->handle
null
null
$response
getMessage
getMessage
$r
$response
$noDoc
$withType
$withoutType
$var1
$var2
MockServer
public function addMultiple($test)
$arg
$this->mockSoapServer
\LaminasTest\Soap\TestAsset\MyResponse[]
\LaminasTest\Soap\TestAsset\MyResponse[]
\LaminasTest\Soap\TestAsset\MyResponse[]
\LaminasTest\Soap\TestAsset\Recursion
getSoap
integer
string[]
string[]
string[]
string[][][]
$return
$bar
$bar
$baz
$foo
$foo
$object
$othervar
$p1
$property1
$property1
$property2
$property2
$recursion
$somevar
$args
$name
$test
$who
$handle
$mockSoapServer
OneWay
TestFunc2
addMultiple
handle
pushOneWay
triggerError
stdClass
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
MockServer
stdClass
$message
ComplexTypeB
public function request($request)
$_SERVER['HTTP_HOST']
$_SERVER['PHP_SELF']
testAddComplexTypeOfNonExistingClassThrowsException
testAddingSingularThenArrayTypeIsRecognizedCorretly
testAddingTypesMultipleTimesIsSavedOnlyOnce
testArrayOfComplexNestedObjectsIsCoveredByStrategyAndAddsAllTypesRecursivly
testArrayOfComplexObjects
testArrayOfObjectWithObject
testArrayOfSimpleObject
testNestingObjectsDeepMakesNoSenseThrowingException
testThatOverridingStrategyIsReset
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttributeNS
getAttributeNS
getAttributeNS
getAttributeNS
$return
testAddComplexTypeArrayOfObject
testAddComplexTypeObject
testAddComplexTypeOfNonExistingClassThrowsException
testFunctionReturningSimpleArrayOfBasicTypes
testNestedTypesDefinitions
$typeName
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
[]
[]
testCompositeApiAddingStragiesToTypes
testCompositeDelegatesAddingComplexTypesToSubStrategies
testCompositeRequiresContextForAddingComplexTypesOtherwiseThrowsException
testCompositeThrowsExceptionOnInvalidStrategy
testCompositeThrowsExceptionOnInvalidStrategyPart2
testCompositeThrowsExceptionOnInvalidType
testConstructorTypeMapSyntax
testGetDefaultStrategy
testDocumentationStrategyCalled
testDoubleClassesAreDiscoveredByStrategy
testOnlyPublicPropertiesAreDiscoveredByStrategy
$strategy
getGetComplexTypeDocumentationParsesDocComment
testGetPropertyDocumentationParsesDocComment
testGetPropertyDocumentationReturnsEmptyString
testGetPropertyDocumentationSkipsAnnotations
$content
$nodes->item(0)
$operationUrl
$serviceUrl
$uri
$this->wsdl
1
public function ampersandInUrlDataProvider(): array
public function dataProviderForAddService(): array
$file
1
checkXMLContent
testAddBinding
testAddBindingOperation
testAddBindingOperationWithAmpersandInUrl
testAddComplexMessage
testAddComplexType
testAddDocumentation
testAddDocumentationToSetInsertsBefore
testAddDocumentationToSomeElmenet
testAddElement
testAddElementException
testAddMessage
testAddPortOperation
testAddPortType
testAddService
testAddServiceWithAmpersandInUrl
testAddSoapBinding
testAddSoapOperation
testAddSoapOperationWithAmpersandInUrl
testAddTypesFromDocument
testAddTypesFromNode
testAddingSameComplexTypeMoreThanOnceIsIgnored
testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionLaminas3910
testClassMap
testComplexTypeDocumentationAddedAsAnnotation
testConstructor
testDumpToFile
testDumpToOutput
testGetComplexTypeBasedOnStrategiesBackwardsCompabilityBoolean
testGetComplexTypeBasedOnStrategiesStringNames
testGetSchema
testGetType
testMultipleSequenceDefinitionsOfSameTypeWillBeRecognizedOnceBySequenceStrategy
testObjectConstructionWithDifferentURI
testSetUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes
testSetUriWithLaminasUriChangesDomDocumentWsdlStructureTnsAndTargetNamespaceAttributes
testTranslateType
testTranslateTypeFromClassMap
testUsingSameComplexTypeTwiceLeadsToReuseOfDefinition
$parameter
$parameter
$faultNodes
$inputNodes
$outputNodes
$parameter
$parameter
array
array
array<array-key, array{0 string|Uri}>
getAttribute
getAttribute
getAttribute
item
item
item
null
$fail
$inputRequest
$outputResponse
$ar[$key]
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getAttribute
getElementsByTagName
getElementsByTagName
getElementsByTagName
hasAttribute
$val
$node
documentNodesTest
* array(
* 'name' => 'MyElement',
* 'sequence' => array(
* array('name' => 'myString', 'type' => 'string'),
* array('name' => 'myInteger', 'type' => 'int')
* )
* );
*
*
* Resulting XML:
*
*
*
*
*
*
*
*
*
*
* @param array $element an xsd:element represented as an array
* @return string xsd:element for the given element array
*/
public function addElement($element)
{
$schema = $this->getSchema();
$elementXml = $this->parseElement($element);
$schema->appendChild($elementXml);
return self::TYPES_NS . ':' . $element['name'];
}
}
PK y)V{U U A src/Wsdl/DocumentationStrategy/DocumentationStrategyInterface.phpnu ٘ elements on complex types
*/
interface DocumentationStrategyInterface
{
/**
* Returns documentation for complex type property
*
* @return string
*/
public function getPropertyDocumentation(ReflectionProperty $property);
/**
* Returns documentation for complex type
*
* @return string
*/
public function getComplexTypeDocumentation(ReflectionClass $class);
}
PK y)V%n)Ba a : src/Wsdl/DocumentationStrategy/ReflectionDocumentation.phpnu ٘ parseDocComment($property->getDocComment());
}
/**
* @return string
*/
public function getComplexTypeDocumentation(ReflectionClass $class)
{
return $this->parseDocComment($class->getDocComment());
}
/**
* @param string $docComment
* @return string
*/
private function parseDocComment($docComment)
{
$documentation = [];
foreach (explode("\n", $docComment) as $i => $line) {
if ($i === 0) {
continue;
}
$line = trim(preg_replace('/\s*\*+/', '', $line));
if (preg_match('/^(@[a-z]|\/)/i', $line)) {
break;
}
// only include newlines if we've already got documentation
if (! empty($documentation) || $line !== '') {
$documentation[] = $line;
}
}
return implode("\n", $documentation);
}
}
PK y)Vv 3 src/Wsdl/ComplexTypeStrategy/ArrayOfTypeComplex.phpnu ٘ scanRegisteredTypes($type)) !== null) {
return $soapType;
}
$singularType = $this->getSingularPhpType($type);
$nestingLevel = $this->getNestedCount($type);
if ($nestingLevel === 0) {
return parent::addComplexType($singularType);
}
if ($nestingLevel !== 1) {
throw new Exception\InvalidArgumentException(
'ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than one level. '
. 'Use array object properties to return deep nested data.'
);
}
// The following blocks define the Array of Object structure
return $this->addArrayOfComplexType($singularType, $type);
}
/**
* Add an ArrayOfType based on the xsd:complexType syntax if type[] is
* detected in return value doc comment.
*
* @param string $singularType e.g. '\MyNamespace\MyClassname'
* @param string $type e.g. '\MyNamespace\MyClassname[]'
* @return string tns:xsd-type e.g. 'tns:ArrayOfMyNamespace.MyClassname'
*/
protected function addArrayOfComplexType($singularType, $type)
{
if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
return $soapType;
}
$xsdComplexTypeName = 'ArrayOf' . $this->getContext()->translateType($singularType);
$xsdComplexType = Wsdl::TYPES_NS . ':' . $xsdComplexTypeName;
// Register type here to avoid recursion
$this->getContext()->addType($type, $xsdComplexType);
// Process singular type using DefaultComplexType strategy
parent::addComplexType($singularType);
// Add array type structure to WSDL document
$dom = $this->getContext()->toDomDocument();
$complexType = $dom->createElementNS(Wsdl::XSD_NS_URI, 'complexType');
$this->getContext()->getSchema()->appendChild($complexType);
$complexType->setAttribute('name', $xsdComplexTypeName);
$complexContent = $dom->createElementNS(Wsdl::XSD_NS_URI, 'complexContent');
$complexType->appendChild($complexContent);
$xsdRestriction = $dom->createElementNS(Wsdl::XSD_NS_URI, 'restriction');
$complexContent->appendChild($xsdRestriction);
$xsdRestriction->setAttribute('base', Wsdl::SOAP_ENC_NS . ':Array');
$xsdAttribute = $dom->createElementNS(Wsdl::XSD_NS_URI, 'attribute');
$xsdRestriction->appendChild($xsdAttribute);
$xsdAttribute->setAttribute('ref', Wsdl::SOAP_ENC_NS . ':arrayType');
$xsdAttribute->setAttributeNS(
Wsdl::WSDL_NS_URI,
'arrayType',
Wsdl::TYPES_NS . ':' . $this->getContext()->translateType($singularType) . '[]'
);
return $xsdComplexType;
}
/**
* From a nested definition with type[], get the singular PHP Type
*
* @param string $type
* @return string
*/
protected function getSingularPhpType($type)
{
return str_replace('[]', '', $type);
}
/**
* Return the array nesting level based on the type name
*
* @param string $type
* @return int
*/
protected function getNestedCount($type)
{
return substr_count($type, '[]');
}
}
PK y)V5BI ( src/Wsdl/ComplexTypeStrategy/AnyType.phpnu ٘ getName();
if (($soapType = $this->scanRegisteredTypes($phpType)) !== null) {
return $soapType;
}
$dom = $this->getContext()->toDomDocument();
$soapTypeName = $this->getContext()->translateType($phpType);
$soapType = Wsdl::TYPES_NS . ':' . $soapTypeName;
// Register type here to avoid recursion
$this->getContext()->addType($phpType, $soapType);
$defaultProperties = $class->getDefaultProperties();
$complexType = $dom->createElementNS(Wsdl::XSD_NS_URI, 'complexType');
$complexType->setAttribute('name', $soapTypeName);
$all = $dom->createElementNS(Wsdl::XSD_NS_URI, 'all');
foreach ($class->getProperties() as $property) {
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
/**
* @todo check if 'xsd:element' must be used here (it may not be
* compatible with using 'complexType' node for describing other
* classes used as attribute types for current class
*/
$element = $dom->createElementNS(Wsdl::XSD_NS_URI, 'element');
$element->setAttribute('name', $propertyName = $property->getName());
$element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0])));
// If the default value is null, then this property is nillable.
if ($defaultProperties[$propertyName] === null) {
$element->setAttribute('nillable', 'true');
}
$this->addPropertyDocumentation($property, $element);
$all->appendChild($element);
}
}
$complexType->appendChild($all);
$this->addComplexTypeDocumentation($class, $complexType);
$this->getContext()->getSchema()->appendChild($complexType);
return $soapType;
}
/**
* @return void
*/
private function addPropertyDocumentation(ReflectionProperty $property, DOMElement $element)
{
if ($this->documentationStrategy instanceof DocumentationStrategyInterface) {
$documentation = $this->documentationStrategy->getPropertyDocumentation($property);
if ($documentation) {
$this->getContext()->addDocumentation($element, $documentation);
}
}
}
/**
* @return void
*/
private function addComplexTypeDocumentation(ReflectionClass $class, DOMElement $element)
{
if ($this->documentationStrategy instanceof DocumentationStrategyInterface) {
$documentation = $this->documentationStrategy->getComplexTypeDocumentation($class);
if ($documentation) {
$this->getContext()->addDocumentation($element, $documentation);
}
}
}
}
PK y)V. = src/Wsdl/ComplexTypeStrategy/ComplexTypeStrategyInterface.phpnu ٘ context = $context;
}
/**
* Return the current WSDL context object
*
* @return Wsdl
*/
public function getContext()
{
return $this->context;
}
/**
* Look through registered types
*
* @param string $phpType
* @return null|string
*/
public function scanRegisteredTypes($phpType)
{
if (array_key_exists($phpType, $this->getContext()->getTypes())) {
$soapTypes = $this->getContext()->getTypes();
return $soapTypes[$phpType];
}
return null;
}
/**
* Sets the strategy for generating complex type documentation
*
* @return void
*/
public function setDocumentationStrategy(DocumentationStrategyInterface $documentationStrategy)
{
$this->documentationStrategy = $documentationStrategy;
}
}
PK y)Vd5vT T * src/Wsdl/ComplexTypeStrategy/Composite.phpnu ٘ Strategy pairs.
*
* @var array
*/
protected $typeMap = [];
/**
* Default Strategy of this composite
*
* @var string|ComplexTypeStrategy
*/
protected $defaultStrategy;
/**
* Context WSDL file that this composite serves
*
* @var Wsdl|null
*/
protected $context;
/**
* Construct Composite WSDL Strategy.
*
* @param array $typeMap
* @param string|ComplexTypeStrategy $defaultStrategy
*/
public function __construct(
array $typeMap = [],
$defaultStrategy = DefaultComplexType::class
) {
foreach ($typeMap as $type => $strategy) {
$this->connectTypeToStrategy($type, $strategy);
}
$this->defaultStrategy = $defaultStrategy;
}
/**
* Connect a complex type to a given strategy.
*
* @param string $type
* @param string|ComplexTypeStrategy $strategy
* @return Composite
* @throws Exception\InvalidArgumentException
*/
public function connectTypeToStrategy($type, $strategy)
{
if (! is_string($type)) {
throw new Exception\InvalidArgumentException('Invalid type given to Composite Type Map.');
}
$this->typeMap[$type] = $strategy;
return $this;
}
/**
* Return default strategy of this composite
*
* @return ComplexTypeStrategy
* @throws Exception\InvalidArgumentException
*/
public function getDefaultStrategy()
{
$strategy = $this->defaultStrategy;
if (is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy();
}
if (! $strategy instanceof ComplexTypeStrategy) {
throw new Exception\InvalidArgumentException(
'Default Strategy for Complex Types is not a valid strategy object.'
);
}
$this->defaultStrategy = $strategy;
return $strategy;
}
/**
* Return specific strategy or the default strategy of this type.
*
* @param string $type
* @return ComplexTypeStrategy
* @throws Exception\InvalidArgumentException
*/
public function getStrategyOfType($type)
{
if (isset($this->typeMap[$type])) {
$strategy = $this->typeMap[$type];
if (is_string($strategy) && class_exists($strategy)) {
$strategy = new $strategy();
}
if (! $strategy instanceof ComplexTypeStrategy) {
throw new Exception\InvalidArgumentException(sprintf(
'Strategy for Complex Type "%s" is not a valid strategy object.',
$type
));
}
$this->typeMap[$type] = $strategy;
} else {
$strategy = $this->getDefaultStrategy();
}
return $strategy;
}
/**
* Method accepts the current WSDL context file.
*
* @return Composite
*/
public function setContext(Wsdl $context)
{
$this->context = $context;
return $this;
}
/**
* Create a complex type based on a strategy
*
* @param string $type
* @return string XSD type
* @throws Exception\InvalidArgumentException
*/
public function addComplexType($type)
{
if (! $this->context instanceof Wsdl) {
throw new Exception\InvalidArgumentException(sprintf(
'Cannot add complex type "%s", no context is set for this composite strategy.',
$type
));
}
$strategy = $this->getStrategyOfType($type);
$strategy->setContext($this->context);
return $strategy->addComplexType($type);
}
}
PK y)V@i 4 src/Wsdl/ComplexTypeStrategy/ArrayOfTypeSequence.phpnu ٘ getNestedCount($type);
if ($nestedCounter > 0) {
$singularType = $this->getSingularType($type);
$complexType = '';
for ($i = 1; $i <= $nestedCounter; $i++) {
$complexType = $this->getTypeBasedOnNestingLevel($singularType, $i);
$complexTypePhp = $singularType . str_repeat('[]', $i);
$childType = $this->getTypeBasedOnNestingLevel($singularType, $i - 1);
$this->addSequenceType($complexType, $childType, $complexTypePhp);
}
return $complexType;
}
if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
// Existing complex type
return $soapType;
}
// New singular complex type
return parent::addComplexType($type);
}
/**
* Return the ArrayOf or simple type name based on the singular xsdtype
* and the nesting level
*
* @param string $singularType
* @param int $level
* @return string
*/
protected function getTypeBasedOnNestingLevel($singularType, $level)
{
if ($level === 0) {
// This is not an Array anymore, return the xsd simple type
return $this->getContext()->getType($singularType);
}
return Wsdl::TYPES_NS
. ':'
. str_repeat('ArrayOf', $level)
. ucfirst($this->getContext()->translateType($singularType));
}
/**
* From a nested definition with type[], get the singular xsd:type
*
* @param string $type
* @return string
*/
protected function getSingularType($type)
{
return str_replace('[]', '', $type);
}
/**
* Return the array nesting level based on the type name
*
* @param string $type
* @return int
*/
protected function getNestedCount($type)
{
return substr_count($type, '[]');
}
/**
* Append the complex type definition to the WSDL via the context access
*
* @param string $arrayType Array type name (e.g. 'tns:ArrayOfArrayOfInt')
* @param string $childType Qualified array items type (e.g. 'xsd:int', 'tns:ArrayOfInt')
* @param string $phpArrayType PHP type (e.g. 'int[][]', '\MyNamespace\MyClassName[][][]')
*/
protected function addSequenceType($arrayType, $childType, $phpArrayType)
{
if ($this->scanRegisteredTypes($phpArrayType) !== null) {
return;
}
// Register type here to avoid recursion
$this->getContext()->addType($phpArrayType, $arrayType);
$dom = $this->getContext()->toDomDocument();
$arrayTypeName = substr($arrayType, strpos($arrayType, ':') + 1);
$complexType = $dom->createElementNS(Wsdl::XSD_NS_URI, 'complexType');
$this->getContext()->getSchema()->appendChild($complexType);
$complexType->setAttribute('name', $arrayTypeName);
$sequence = $dom->createElementNS(Wsdl::XSD_NS_URI, 'sequence');
$complexType->appendChild($sequence);
$element = $dom->createElementNS(Wsdl::XSD_NS_URI, 'element');
$sequence->appendChild($element);
$element->setAttribute('name', 'item');
$element->setAttribute('type', $childType);
$element->setAttribute('minOccurs', 0);
$element->setAttribute('maxOccurs', 'unbounded');
}
}
PK y)VN
?| | src/Server.phpnu ٘ PHP class pairings for handling return/incoming values
*
* @var array
*/
protected $classmap;
/**
* Encoding
*
* @var string
*/
protected $encoding;
/**
* Registered fault exceptions
*
* @var array
*/
protected $faultExceptions = [];
/**
* Container for caught exception during business code execution
*
* @var Exception
*/
protected $caughtException;
/**
* SOAP Server Features
*
* @var int
*/
protected $features;
/**
* Functions registered with this server; may be either an array or the SOAP_FUNCTIONS_ALL constant
*
* @var array|int
*/
protected $functions = [];
/**
* Object registered with this server
*
* @var object
*/
protected $object;
/**
* Informs if the soap server is in debug mode
*
* @var bool
*/
protected $debug = false;
/**
* Persistence mode; should be one of the SOAP persistence constants
*
* @var int
*/
protected $persistence;
/**
* Request XML
*
* @var string
*/
protected $request;
/**
* Response XML
*
* @var string
*/
protected $response;
/**
* Flag: whether or not {@link handle()} should return a response instead of automatically emitting it.
*
* @var bool
*/
protected $returnResponse = false;
/**
* SOAP version to use; SOAP_1_2 by default, to allow processing of headers
*
* @var int
*/
protected $soapVersion = SOAP_1_2;
/**
* Array of type mappings
*
* @var array
*/
protected $typemap;
/**
* URI namespace for SOAP server
*
* @var string URI
*/
protected $uri;
/**
* URI or path to WSDL
*
* @var string
*/
protected $wsdl;
/**
* WSDL Caching Options of SOAP Server
*
* @var mixed
*/
protected $wsdlCache;
/**
* The send_errors Options of SOAP Server
*
* @var bool
*/
protected $sendErrors;
/**
* Allows LIBXML_PARSEHUGE Options of DOMDocument->loadXML( string $source [, int $options = 0 ] ) to be set
*
* @var bool
*/
protected $parseHuge;
/**
* Constructor
*
* Sets display_errors INI setting to off (prevent client errors due to bad
* XML in response). Registers {@link handlePhpErrors()} as error handler
* for E_USER_ERROR.
*
* If $wsdl is provided, it is passed on to {@link setWSDL()}; if any
* options are specified, they are passed on to {@link setOptions()}.
*
* @param string $wsdl
* @param array $options
* @throws ExtensionNotLoadedException
*/
public function __construct($wsdl = null, ?array $options = null)
{
if (! extension_loaded('soap')) {
throw new ExtensionNotLoadedException('SOAP extension is not loaded.');
}
if (null !== $wsdl) {
$this->setWSDL($wsdl);
}
if (null !== $options) {
$this->setOptions($options);
}
}
/**
* Set Options
*
* Allows setting options as an associative array of option => value pairs.
*
* @param array|Traversable $options
* @return self
*/
public function setOptions($options)
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
foreach ($options as $key => $value) {
switch (strtolower($key)) {
case 'actor':
$this->setActor($value);
break;
case 'classmap':
case 'class_map':
$this->setClassmap($value);
break;
case 'typemap':
case 'type_map':
$this->setTypemap($value);
break;
case 'encoding':
$this->setEncoding($value);
break;
case 'soapversion':
case 'soap_version':
$this->setSoapVersion($value);
break;
case 'uri':
$this->setUri($value);
break;
case 'wsdl':
$this->setWSDL($value);
break;
case 'cache_wsdl':
$this->setWSDLCache($value);
break;
case 'features':
$this->setSoapFeatures($value);
break;
case 'send_errors':
$this->setSendErrors($value);
break;
case 'parse_huge':
$this->setParseHuge($value);
break;
default:
break;
}
}
return $this;
}
/**
* Return array of options suitable for using with SoapServer constructor
*
* @return array
*/
public function getOptions()
{
$options = [];
if (null !== $this->actor) {
$options['actor'] = $this->getActor();
}
if (null !== $this->classmap) {
$options['classmap'] = $this->getClassmap();
}
if (null !== $this->typemap) {
$options['typemap'] = $this->getTypemap();
}
if (null !== $this->encoding) {
$options['encoding'] = $this->getEncoding();
}
if (null !== $this->soapVersion) {
$options['soap_version'] = $this->getSoapVersion();
}
if (null !== $this->uri) {
$options['uri'] = $this->getUri();
}
if (null !== $this->features) {
$options['features'] = $this->getSoapFeatures();
}
if (null !== $this->wsdlCache) {
$options['cache_wsdl'] = $this->getWSDLCache();
}
if (null !== $this->sendErrors) {
$options['send_errors'] = $this->getSendErrors();
}
if (null !== $this->parseHuge) {
$options['parse_huge'] = $this->getParseHuge();
}
return $options;
}
/**
* Set encoding
*
* @param string $encoding
* @return self
* @throws InvalidArgumentException With invalid encoding argument.
*/
public function setEncoding($encoding)
{
if (! is_string($encoding)) {
throw new InvalidArgumentException('Invalid encoding specified');
}
$this->encoding = $encoding;
return $this;
}
/**
* Get encoding
*
* @return string
*/
public function getEncoding()
{
return $this->encoding;
}
/**
* Set SOAP version
*
* @param int $version One of the SOAP_1_1 or SOAP_1_2 constants
* @return self
* @throws InvalidArgumentException With invalid soap version argument.
*/
public function setSoapVersion($version)
{
if (! in_array($version, [SOAP_1_1, SOAP_1_2])) {
throw new InvalidArgumentException('Invalid soap version specified');
}
$this->soapVersion = $version;
return $this;
}
/**
* Get SOAP version
*
* @return int
*/
public function getSoapVersion()
{
return $this->soapVersion;
}
/**
* Check for valid URN
*
* @param string $urn
* @return true
* @throws InvalidArgumentException On invalid URN.
*/
public function validateUrn($urn)
{
$scheme = parse_url($urn, PHP_URL_SCHEME);
if ($scheme === false || $scheme === null) {
throw new InvalidArgumentException('Invalid URN');
}
return true;
}
/**
* Set actor
*
* Actor is the actor URI for the server.
*
* @param string $actor
* @return self
*/
public function setActor($actor)
{
$this->validateUrn($actor);
$this->actor = $actor;
return $this;
}
/**
* Retrieve actor
*
* @return string
*/
public function getActor()
{
return $this->actor;
}
/**
* Set URI
*
* URI in SoapServer is actually the target namespace, not a URI; $uri must begin with 'urn:'.
*
* @param string $uri
* @return self
*/
public function setUri($uri)
{
$this->validateUrn($uri);
$this->uri = $uri;
return $this;
}
/**
* Retrieve URI
*
* @return string
*/
public function getUri()
{
return $this->uri;
}
/**
* Set classmap
*
* @param array $classmap
* @return self
* @throws InvalidArgumentException For any invalid class in the class map.
*/
public function setClassmap($classmap)
{
if (! is_array($classmap)) {
throw new InvalidArgumentException('Classmap must be an array');
}
foreach ($classmap as $class) {
if (! class_exists($class)) {
throw new InvalidArgumentException('Invalid class in class map');
}
}
$this->classmap = $classmap;
return $this;
}
/**
* Retrieve classmap
*
* @return mixed
*/
public function getClassmap()
{
return $this->classmap;
}
/**
* Set typemap with xml to php type mappings with appropriate validation.
*
* @param array $typeMap
* @return self
* @throws InvalidArgumentException
*/
public function setTypemap($typeMap)
{
if (! is_array($typeMap)) {
throw new InvalidArgumentException('Typemap must be an array');
}
foreach ($typeMap as $type) {
if (! is_callable($type['from_xml'])) {
throw new InvalidArgumentException(sprintf(
'Invalid from_xml callback for type: %s',
$type['type_name']
));
}
if (! is_callable($type['to_xml'])) {
throw new InvalidArgumentException('Invalid to_xml callback for type: ' . $type['type_name']);
}
}
$this->typemap = $typeMap;
return $this;
}
/**
* Retrieve typemap
*
* @return array
*/
public function getTypemap()
{
return $this->typemap;
}
/**
* Set wsdl
*
* @param string $wsdl URI or path to a WSDL
* @return self
*/
public function setWSDL($wsdl)
{
$this->wsdl = $wsdl;
return $this;
}
/**
* Retrieve wsdl
*
* @return string
*/
public function getWSDL()
{
return $this->wsdl;
}
/**
* Set the SOAP Feature options.
*
* @param string|int $feature
* @return self
*/
public function setSoapFeatures($feature)
{
$this->features = $feature;
return $this;
}
/**
* Return current SOAP Features options
*
* @return int
*/
public function getSoapFeatures()
{
return $this->features;
}
/**
* Set the SOAP WSDL Caching Options
*
* @param string|int|bool $options
* @return self
*/
public function setWSDLCache($options)
{
$this->wsdlCache = $options;
return $this;
}
/**
* Get current SOAP WSDL Caching option
*
* @return null|string|int|bool
*/
public function getWSDLCache()
{
return $this->wsdlCache;
}
/**
* Set the SOAP send_errors Option
*
* @param bool $sendErrors
* @return self
*/
public function setSendErrors($sendErrors)
{
$this->sendErrors = (bool) $sendErrors;
return $this;
}
/**
* Get current SOAP send_errors option
*
* @return bool
*/
public function getSendErrors()
{
return $this->sendErrors;
}
/**
* Set flag to allow DOMDocument->loadXML() to parse huge nodes
*
* @param bool $parseHuge
* @return self
*/
public function setParseHuge($parseHuge)
{
$this->parseHuge = (bool) $parseHuge;
return $this;
}
/**
* Get flag to allow DOMDocument->loadXML() to parse huge nodes
*
* @return bool
*/
public function getParseHuge()
{
return $this->parseHuge;
}
/**
* Attach a function as a server method
*
* @param array|string $function Function name, array of function names to attach,
* or SOAP_FUNCTIONS_ALL to attach all functions
* @param string $namespace Ignored
* @return self
* @throws InvalidArgumentException On invalid functions.
*/
public function addFunction($function, $namespace = '')
{
// Bail early if set to SOAP_FUNCTIONS_ALL
if ($this->functions === SOAP_FUNCTIONS_ALL) {
return $this;
}
if (is_array($function)) {
foreach ($function as $func) {
if (is_string($func) && function_exists($func)) {
$this->functions[] = $func;
} else {
throw new InvalidArgumentException('One or more invalid functions specified in array');
}
}
} elseif (is_string($function) && function_exists($function)) {
$this->functions[] = $function;
} elseif ($function === SOAP_FUNCTIONS_ALL) {
$this->functions = SOAP_FUNCTIONS_ALL;
} else {
throw new InvalidArgumentException('Invalid function specified');
}
if (is_array($this->functions)) {
$this->functions = array_unique($this->functions);
}
return $this;
}
/**
* Attach a class to a server
*
* Accepts a class name to use when handling requests. Any additional
* arguments will be passed to that class' constructor when instantiated.
*
* See {@link setObject()} to set pre-configured object instances as request handlers.
*
* @param string|object $class Class name or object instance which executes
* SOAP Requests at endpoint.
* @param string $namespace
* @param null|array $argv
* @return self
* @throws InvalidArgumentException If called more than once, or if class does not exist.
*/
public function setClass($class, $namespace = '', $argv = null)
{
if (isset($this->class)) {
throw new InvalidArgumentException(
'A class has already been registered with this soap server instance'
);
}
if (is_object($class)) {
return $this->setObject($class);
}
if (! is_string($class)) {
throw new InvalidArgumentException(sprintf(
'Invalid class argument (%s)',
gettype($class)
));
}
if (! class_exists($class)) {
throw new InvalidArgumentException(sprintf(
'Class "%s" does not exist',
$class
));
}
$this->class = $class;
if (2 < func_num_args()) {
$argv = func_get_args();
$this->classArgs = array_slice($argv, 2);
}
return $this;
}
/**
* Attach an object to a server
*
* Accepts an instantiated object to use when handling requests.
*
* @param object $object
* @return self
* @throws InvalidArgumentException
*/
public function setObject($object)
{
if (! is_object($object)) {
throw new InvalidArgumentException(sprintf(
'Invalid object argument (%s)',
gettype($object)
));
}
if (isset($this->object)) {
throw new InvalidArgumentException(
'An object has already been registered with this soap server instance'
);
}
$this->object = $object;
return $this;
}
/**
* Return a server definition array
*
* Returns a list of all functions registered with {@link addFunction()},
* merged with all public methods of the class set with {@link setClass()}
* (if any).
*
* @return array
*/
public function getFunctions()
{
$functions = [];
if (null !== $this->class) {
$functions = get_class_methods($this->class);
} elseif (null !== $this->object) {
$functions = get_class_methods($this->object);
}
return array_merge((array) $this->functions, $functions);
}
/**
* Unimplemented: Load server definition
*
* @param array $definition
* @throws RuntimeException Unimplemented.
*/
public function loadFunctions($definition)
{
throw new RuntimeException('Unimplemented method.');
}
/**
* Set server persistence
*
* @param int $mode SOAP_PERSISTENCE_SESSION or SOAP_PERSISTENCE_REQUEST constants
* @return self
* @throws InvalidArgumentException
*/
public function setPersistence($mode)
{
if (! in_array($mode, [SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST])) {
throw new InvalidArgumentException('Invalid persistence mode specified');
}
$this->persistence = $mode;
return $this;
}
/**
* Get server persistence
*
* @return int
*/
public function getPersistence()
{
return $this->persistence;
}
/**
* Set request
*
* $request may be any of:
* - DOMDocument; if so, then cast to XML
* - DOMNode; if so, then grab owner document and cast to XML
* - SimpleXMLElement; if so, then cast to XML
* - stdClass; if so, calls __toString() and verifies XML
* - string; if so, verifies XML
*
* @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request
* @return self
* @throws InvalidArgumentException
*/
protected function setRequest($request)
{
$xml = null;
if ($request instanceof DOMDocument) {
$xml = $request->saveXML();
} elseif ($request instanceof DOMNode) {
$xml = $request->ownerDocument->saveXML();
} elseif ($request instanceof SimpleXMLElement) {
$xml = $request->asXML();
} elseif (is_object($request) || is_string($request)) {
if (is_object($request)) {
$xml = $request->__toString();
} else {
$xml = $request;
}
$xml = trim($xml);
if (strlen($xml) === 0) {
throw new InvalidArgumentException('Empty request');
}
$loadEntities = $this->disableEntityLoader(true);
$dom = new DOMDocument();
if (true === $this->getParseHuge()) {
$loadStatus = $dom->loadXML($xml, LIBXML_PARSEHUGE);
} else {
$loadStatus = $dom->loadXML($xml);
}
$this->disableEntityLoader($loadEntities);
// @todo check libxml errors ? validate document ?
if (! $loadStatus) {
throw new InvalidArgumentException('Invalid XML');
}
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
throw new InvalidArgumentException('Invalid XML: Detected use of illegal DOCTYPE');
}
}
}
$this->request = $xml;
return $this;
}
/**
* Retrieve request XML
*
* @return string
*/
public function getLastRequest()
{
return $this->request;
}
/**
* Set return response flag
*
* If true, {@link handle()} will return the response instead of
* automatically sending it back to the requesting client.
*
* The response is always available via {@link getResponse()}.
*
* @param bool $flag
* @return self
*/
public function setReturnResponse($flag = true)
{
$this->returnResponse = (bool) $flag;
return $this;
}
/**
* Retrieve return response flag
*
* @return bool
*/
public function getReturnResponse()
{
return $this->returnResponse;
}
/**
* Get response XML
*
* @return string
*/
public function getResponse()
{
return $this->response;
}
/**
* Get SoapServer object
*
* Uses {@link $wsdl} and return value of {@link getOptions()} to instantiate
* SoapServer object, and then registers any functions or class with it, as
* well as persistence.
*
* @return SoapServer
*/
public function getSoap()
{
if ($this->server instanceof SoapServer) {
return $this->server;
}
$options = $this->getOptions();
$server = new SoapServer($this->wsdl, $options);
if (! empty($this->functions)) {
$server->addFunction($this->functions);
}
if (! empty($this->class)) {
$args = $this->classArgs;
array_unshift($args, $this->class);
call_user_func_array([$server, 'setClass'], $args);
}
if (! empty($this->object)) {
$server->setObject($this->object);
}
if (null !== $this->persistence) {
$server->setPersistence($this->persistence);
}
$this->server = $server;
return $this->server;
}
/**
* Proxy for _getSoap method
*
* @see _getSoap
*
* @return SoapServer the soapServer instance
public function getSoap()
{
return $this->_getSoap();
}
*/
/**
* Handle a request
*
* Instantiates SoapServer object with options set in object, and
* dispatches its handle() method.
*
* $request may be any of:
* - DOMDocument; if so, then cast to XML
* - DOMNode; if so, then grab owner document and cast to XML
* - SimpleXMLElement; if so, then cast to XML
* - stdClass; if so, calls __toString() and verifies XML
* - string; if so, verifies XML
*
* If no request is passed, pulls request using php:://input (for
* cross-platform compatibility purposes).
*
* @param DOMDocument|DOMNode|SimpleXMLElement|stdClass|string $request Optional request
* @return void|string
*/
public function handle($request = null)
{
if (null === $request) {
$request = file_get_contents('php://input');
}
// Set Server error handler
$displayErrorsOriginalState = $this->initializeSoapErrorContext();
$setRequestException = null;
try {
$this->setRequest($request);
} catch (Exception $e) {
$setRequestException = $e;
}
$soap = $this->getSoap();
$fault = false;
$this->response = '';
if ($setRequestException instanceof Exception) {
// Create SOAP fault message if we've caught a request exception
$fault = $this->fault($setRequestException->getMessage(), 'Sender');
} else {
ob_start();
try {
$soap->handle($this->request);
} catch (Exception $e) {
$fault = $this->fault($e);
}
$this->response = ob_get_clean();
}
// Restore original error handler
restore_error_handler();
ini_set('display_errors', (string) $displayErrorsOriginalState);
// Send a fault, if we have one
if ($fault instanceof SoapFault && ! $this->returnResponse) {
$soap->fault($fault->faultcode, $fault->getMessage());
return;
}
// Echo the response, if we're not returning it
if (! $this->returnResponse) {
echo $this->response;
return;
}
// Return a fault, if we have it
if ($fault instanceof SoapFault) {
return $fault;
}
// Return the response
return $this->response;
}
/**
* Method initializes the error context that the SOAPServer environment will run in.
*
* @return bool display_errors original value
*/
protected function initializeSoapErrorContext()
{
$displayErrorsOriginalState = ini_get('display_errors');
ini_set('display_errors', '0');
set_error_handler([$this, 'handlePhpErrors'], E_USER_ERROR);
return $displayErrorsOriginalState;
}
/**
* Set the debug mode.
* In debug mode, all exceptions are send to the client.
*
* @param bool $debug
* @return self
*/
public function setDebugMode($debug)
{
$this->debug = $debug;
return $this;
}
/**
* Validate and register fault exception
*
* @param string|array $class Exception class or array of exception classes
* @return self
* @throws InvalidArgumentException
*/
public function registerFaultException($class)
{
if (is_array($class)) {
foreach ($class as $row) {
$this->registerFaultException($row);
}
} elseif (
is_string($class)
&& class_exists($class)
&& (is_subclass_of($class, 'Exception') || 'Exception' === $class)
) {
$ref = new ReflectionClass($class);
$this->faultExceptions[] = $ref->getName();
$this->faultExceptions = array_unique($this->faultExceptions);
} else {
throw new InvalidArgumentException(
'Argument for Laminas\Soap\Server::registerFaultException should be'
. ' string or array of strings with valid exception names'
);
}
return $this;
}
/**
* Checks if provided fault name is registered as valid in this server.
*
* @param string $fault Name of a fault class
* @return bool
*/
public function isRegisteredAsFaultException($fault)
{
if ($this->debug) {
return true;
}
$ref = new ReflectionClass($fault);
$classNames = $ref->getName();
return in_array($classNames, $this->faultExceptions);
}
/**
* Deregister a fault exception from the fault exception stack
*
* @param string $class
* @return bool
*/
public function deregisterFaultException($class)
{
if (in_array($class, $this->faultExceptions, true)) {
$index = array_search($class, $this->faultExceptions);
unset($this->faultExceptions[$index]);
return true;
}
return false;
}
/**
* Return fault exceptions list
*
* @return array
*/
public function getFaultExceptions()
{
return $this->faultExceptions;
}
/**
* Return caught exception during business code execution
*
* @return null|Exception caught exception
*/
public function getException()
{
return $this->caughtException;
}
/**
* Generate a server fault
*
* Note that the arguments are reverse to those of SoapFault.
*
* If an exception is passed as the first argument, its message and code
* will be used to create the fault object if it has been registered via
* {@Link registerFaultException()}.
*
* @link http://www.w3.org/TR/soap12-part1/#faultcodes
*
* @param string|Exception $fault
* @param string $code SOAP Fault Codes
* @return SoapFault
*/
public function fault($fault = null, $code = 'Receiver')
{
$this->caughtException = is_string($fault) ? new Exception($fault) : $fault;
if ($fault instanceof Exception) {
if ($this->isRegisteredAsFaultException($fault)) {
$message = $fault->getMessage();
$eCode = $fault->getCode();
$code = empty($eCode) ? $code : $eCode;
} else {
$message = 'Unknown error';
}
} elseif (is_string($fault)) {
$message = $fault;
} else {
$message = 'Unknown error';
}
$allowedFaultModes = [
'VersionMismatch',
'MustUnderstand',
'DataEncodingUnknown',
'Sender',
'Receiver',
'Server',
];
if (! in_array($code, $allowedFaultModes)) {
$code = 'Receiver';
}
return new SoapFault($code, $message);
}
/**
* Throw PHP errors as SoapFaults
*
* @param int $errno
* @param string $errstr
* @throws SoapFault
*/
public function handlePhpErrors($errno, $errstr)
{
throw $this->fault($errstr, 'Receiver');
}
/**
* Disable the ability to load external XML entities based on libxml version
*
* If we are using libxml < 2.9, unsafe XML entity loading must be
* disabled with a flag.
*
* If we are using libxml >= 2.9, XML entity loading is disabled by default.
*
* @param bool $flag
* @return bool
*/
private function disableEntityLoader($flag = true)
{
if (LIBXML_VERSION < 20900) {
return libxml_disable_entity_loader($flag);
}
return $flag;
}
}
PK y)VŤUH UH src/AutoDiscover.phpnu ٘ 'encoded',
'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/",
];
/**
* soap:operation style
*
* @var array
*/
protected $bindingStyle = [
'style' => 'rpc',
'transport' => 'http://schemas.xmlsoap.org/soap/http',
];
/**
* Name of the class to handle the WSDL creation.
*
* @var string
*/
protected $wsdlClass = Wsdl::class;
/**
* Class Map of PHP to WSDL types.
*
* @var array
*/
protected $classMap = [];
/**
* Discovery strategy for types and other method details.
*
* @var DiscoveryStrategy
*/
protected $discoveryStrategy;
/**
* Constructor
*
* @param null|string|Uri\Uri $endpointUri
* @param null|string $wsdlClass
* @param null|array $classMap
*/
public function __construct(
?ComplexTypeStrategy $strategy = null,
$endpointUri = null,
$wsdlClass = null,
array $classMap = []
) {
$this->reflection = new Reflection();
$this->setDiscoveryStrategy(new ReflectionDiscovery());
if (null !== $strategy) {
$this->setComplexTypeStrategy($strategy);
}
if (null !== $endpointUri) {
$this->setUri($endpointUri);
}
if (null !== $wsdlClass) {
$this->setWsdlClass($wsdlClass);
}
$this->setClassMap($classMap);
}
/**
* Set the discovery strategy for method type and other information.
*
* @return self
*/
public function setDiscoveryStrategy(DiscoveryStrategy $discoveryStrategy)
{
$this->discoveryStrategy = $discoveryStrategy;
return $this;
}
/**
* Get the discovery strategy.
*
* @return DiscoveryStrategy
*/
public function getDiscoveryStrategy()
{
return $this->discoveryStrategy;
}
/**
* Get the class map of php to wsdl mappings.
*
* @return array
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* Set the class map of php to wsdl mappings.
*
* @param array $classMap
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setClassMap($classMap)
{
if (! is_array($classMap)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an array; received "%s"',
__METHOD__,
is_object($classMap) ? get_class($classMap) : gettype($classMap)
));
}
$this->classMap = $classMap;
return $this;
}
/**
* Set service name
*
* @param string $serviceName
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setServiceName($serviceName)
{
$matches = [];
// first character must be letter or underscore {@see http://www.w3.org/TR/wsdl#_document-n}
$i = preg_match('/^[a-z\_]/ims', $serviceName, $matches);
if ($i !== 1) {
throw new Exception\InvalidArgumentException('Service Name must start with letter or _');
}
$this->serviceName = $serviceName;
return $this;
}
/**
* Get service name
*
* @return string
* @throws Exception\RuntimeException
*/
public function getServiceName()
{
if (! $this->serviceName) {
if ($this->class) {
return $this->reflection->reflectClass($this->class)->getShortName();
} else {
throw new Exception\RuntimeException('No service name given. Call AutoDiscover::setServiceName().');
}
}
return $this->serviceName;
}
/**
* Set the location at which the WSDL file will be available.
*
* @param Uri\Uri|string $uri
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setUri($uri)
{
if (! is_string($uri) && ! $uri instanceof Uri\Uri) {
throw new Exception\InvalidArgumentException(
'Argument to \Laminas\Soap\AutoDiscover::setUri should be string or \Laminas\Uri\Uri instance.'
);
}
$uri = trim($uri);
$uri = htmlspecialchars($uri, ENT_QUOTES, 'UTF-8', false);
if (empty($uri)) {
throw new Exception\InvalidArgumentException('Uri contains invalid characters or is empty');
}
$this->uri = $uri;
return $this;
}
/**
* Return the current Uri that the SOAP WSDL Service will be located at.
*
* @return Uri\Uri
* @throws Exception\RuntimeException
*/
public function getUri()
{
if ($this->uri === null) {
throw new Exception\RuntimeException(
'Missing uri. You have to explicitly configure the Endpoint Uri by calling AutoDiscover::setUri().'
);
}
if (is_string($this->uri)) {
$this->uri = Uri\UriFactory::factory($this->uri);
}
return $this->uri;
}
/**
* Set the name of the WSDL handling class.
*
* @param string $wsdlClass
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setWsdlClass($wsdlClass)
{
if (! is_string($wsdlClass) && ! is_subclass_of($wsdlClass, Wsdl::class)) {
throw new Exception\InvalidArgumentException(
'No \Laminas\Soap\Wsdl subclass given to Laminas\Soap\AutoDiscover::setWsdlClass as string.'
);
}
$this->wsdlClass = $wsdlClass;
return $this;
}
/**
* Return the name of the WSDL handling class.
*
* @return string
*/
public function getWsdlClass()
{
return $this->wsdlClass;
}
/**
* Set options for all the binding operations soap:body elements.
*
* By default the options are set to 'use' => 'encoded' and
* 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/".
*
* @param array $operationStyle
* @return self
* @throws Exception\InvalidArgumentException
*/
public function setOperationBodyStyle(array $operationStyle = [])
{
if (! isset($operationStyle['use'])) {
throw new Exception\InvalidArgumentException('Key "use" is required in Operation soap:body style.');
}
$this->operationBodyStyle = $operationStyle;
return $this;
}
/**
* Set Binding soap:binding style.
*
* By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'.
*
* @param array $bindingStyle
* @return self
*/
public function setBindingStyle(array $bindingStyle = [])
{
if (isset($bindingStyle['style'])) {
$this->bindingStyle['style'] = $bindingStyle['style'];
}
if (isset($bindingStyle['transport'])) {
$this->bindingStyle['transport'] = $bindingStyle['transport'];
}
return $this;
}
/**
* Set the strategy that handles functions and classes that are added AFTER this call.
*
* @return self
*/
public function setComplexTypeStrategy(ComplexTypeStrategy $strategy)
{
$this->strategy = $strategy;
return $this;
}
/**
* Set the Class the SOAP server will use
*
* @param string $class Class Name
* @return self
*/
public function setClass($class)
{
$this->class = $class;
return $this;
}
/**
* Add a Single or Multiple Functions to the WSDL
*
* @param string $function Function Name
* @return self
* @throws Exception\InvalidArgumentException
*/
public function addFunction($function)
{
if (is_array($function)) {
foreach ($function as $row) {
$this->addFunction($row);
}
} elseif (is_string($function)) {
if (function_exists($function)) {
$this->functions[] = $function;
} else {
throw new Exception\InvalidArgumentException(
'Argument to Laminas\Soap\AutoDiscover::addFunction should be a valid function name.'
);
}
} else {
throw new Exception\InvalidArgumentException(
'Argument to Laminas\Soap\AutoDiscover::addFunction should be string or array of strings.'
);
}
return $this;
}
/**
* Generate the WSDL for a service class.
*
* @return Wsdl
*/
protected function generateClass()
{
return $this->generateWsdl($this->reflection->reflectClass($this->class)->getMethods());
}
/**
* Generate the WSDL for a set of functions.
*
* @return Wsdl
*/
protected function generateFunctions()
{
$methods = [];
foreach (array_unique($this->functions) as $func) {
$methods[] = $this->reflection->reflectFunction($func);
}
return $this->generateWsdl($methods);
}
/**
* Generate the WSDL for a set of reflection method instances.
*
* @param array $reflectionMethods
* @return Wsdl
*/
protected function generateWsdl(array $reflectionMethods)
{
$uri = $this->getUri();
$serviceName = $this->getServiceName();
$wsdl = new $this->wsdlClass($serviceName, $uri, $this->strategy, $this->classMap);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($serviceName . 'Port');
$binding = $wsdl->addBinding($serviceName . 'Binding', Wsdl::TYPES_NS . ':' . $serviceName . 'Port');
$wsdl->addSoapBinding($binding, $this->bindingStyle['style'], $this->bindingStyle['transport']);
$wsdl->addService(
$serviceName . 'Service',
$serviceName . 'Port',
Wsdl::TYPES_NS . ':' . $serviceName . 'Binding',
$uri
);
foreach ($reflectionMethods as $method) {
$this->addFunctionToWsdl($method, $wsdl, $port, $binding);
}
return $wsdl;
}
/**
* Add a function to the WSDL document.
*
* @param Reflection\AbstractFunction $function function to add
* @param Wsdl $wsdl WSDL document
* @param DOMElement $port wsdl:portType
* @param DOMElement $binding wsdl:binding
* @throws Exception\InvalidArgumentException
*/
protected function addFunctionToWsdl($function, $wsdl, $port, $binding)
{
$uri = $this->getUri();
// We only support one prototype: the one with the maximum number of arguments
$prototype = null;
$maxNumArgumentsOfPrototype = -1;
foreach ($function->getPrototypes() as $tmpPrototype) {
$numParams = count($tmpPrototype->getParameters());
if ($numParams > $maxNumArgumentsOfPrototype) {
$maxNumArgumentsOfPrototype = $numParams;
$prototype = $tmpPrototype;
}
}
if ($prototype === null) {
throw new Exception\InvalidArgumentException(sprintf(
'No prototypes could be found for the "%s" function',
$function->getName()
));
}
$functionName = $wsdl->translateType($function->getName());
// Add the input message (parameters)
$args = [];
if ($this->bindingStyle['style'] === 'document') {
// Document style: wrap all parameters in a sequence element
$sequence = [];
foreach ($prototype->getParameters() as $param) {
$sequenceElement = [
'name' => $param->getName(),
'type' => $wsdl->getType($this->discoveryStrategy->getFunctionParameterType($param)),
];
if ($param->isOptional()) {
$sequenceElement['nillable'] = 'true';
}
$sequence[] = $sequenceElement;
}
$element = [
'name' => $functionName,
'sequence' => $sequence,
];
// Add the wrapper element part, which must be named 'parameters'
$args['parameters'] = ['element' => $wsdl->addElement($element)];
} else {
// RPC style: add each parameter as a typed part
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = [
'type' => $wsdl->getType($this->discoveryStrategy->getFunctionParameterType($param)),
];
}
}
$wsdl->addMessage($functionName . 'In', $args);
$isOneWayMessage = $this->discoveryStrategy->isFunctionOneWay($function, $prototype);
if ($isOneWayMessage === false) {
// Add the output message (return value)
$args = [];
if ($this->bindingStyle['style'] === 'document') {
// Document style: wrap the return value in a sequence element
$sequence = [];
if ($prototype->getReturnType() !== "void") {
$sequence[] = [
'name' => $functionName . 'Result',
'type' => $wsdl->getType(
$this->discoveryStrategy->getFunctionReturnType($function, $prototype)
),
];
}
$element = [
'name' => $functionName . 'Response',
'sequence' => $sequence,
];
// Add the wrapper element part, which must be named 'parameters'
$args['parameters'] = ['element' => $wsdl->addElement($element)];
} elseif ($prototype->getReturnType() !== "void") {
// RPC style: add the return value as a typed part
$args['return'] = [
'type' => $wsdl->getType($this->discoveryStrategy->getFunctionReturnType($function, $prototype)),
];
}
$wsdl->addMessage($functionName . 'Out', $args);
}
// Add the portType operation
if ($isOneWayMessage === false) {
$portOperation = $wsdl->addPortOperation(
$port,
$functionName,
Wsdl::TYPES_NS . ':' . $functionName . 'In',
Wsdl::TYPES_NS . ':' . $functionName . 'Out'
);
} else {
$portOperation = $wsdl->addPortOperation(
$port,
$functionName,
Wsdl::TYPES_NS . ':' . $functionName . 'In',
false
);
}
$desc = $this->discoveryStrategy->getFunctionDocumentation($function);
if (strlen($desc) > 0) {
$wsdl->addDocumentation($portOperation, $desc);
}
// When using the RPC style, make sure the operation style includes a 'namespace'
// attribute (WS-I Basic Profile 1.1 R2717)
$operationBodyStyle = $this->operationBodyStyle;
if ($this->bindingStyle['style'] === 'rpc' && ! isset($operationBodyStyle['namespace'])) {
$operationBodyStyle['namespace'] = '' . $uri;
}
// Add the binding operation
if ($isOneWayMessage === false) {
$operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle, $operationBodyStyle);
} else {
$operation = $wsdl->addBindingOperation($binding, $functionName, $operationBodyStyle);
}
$wsdl->addSoapOperation($operation, $uri . '#' . $functionName);
}
/**
* Generate the WSDL file from the configured input.
*
* @return Wsdl
* @throws Exception\RuntimeException
*/
public function generate()
{
if ($this->class && $this->functions) {
throw new Exception\RuntimeException('Can either dump functions or a class as a service, not both.');
}
if ($this->class) {
$wsdl = $this->generateClass();
} else {
$wsdl = $this->generateFunctions();
}
return $wsdl;
}
/**
* Proxy to WSDL dump function
*
* @param string $filename
* @return bool
* @throws Exception\RuntimeException
*/
public function dump($filename)
{
return $this->generate()->dump($filename);
}
/**
* Proxy to WSDL toXml() function
*
* @return string
* @throws Exception\RuntimeException
*/
public function toXml()
{
return $this->generate()->toXml();
}
/**
* Handle WSDL document.
*/
public function handle()
{
header('Content-Type: text/xml');
echo $this->toXml();
}
}
PK y)VHi i % src/Server/DocumentLiteralWrapper.phpnu ٘
*
* {
* /**
* * @param int $x
* * @param int $y
* * @return int
* *
* public function add($x, $y)
* {
* }
* }
*
*
* The document/literal wrapper pattern would lead php ext/soap to generate a
* single "request" object that contains $x and $y properties. To solve this a
* wrapper service is needed that extracts the properties and delegates a
* proper call to the underlying service.
*
* The input variable from a document/literal SOAP-call to the client
* MyCalculatorServiceClient#add(10, 20) would lead PHP ext/soap to create
* the following request object:
*
*
* $addRequest = new \stdClass;
* $addRequest->x = 10;
* $addRequest->y = 20;
*
*
* This object does not match the signature of the server-side
* MyCalculatorService and lead to failure.
*
* Also the response object in this case is supposed to be an array
* or object with a property "addResult":
*
*
* $addResponse = new \stdClass;
* $addResponse->addResult = 30;
*
*
* To keep your service object code free from this implementation detail
* of SOAP this wrapper service handles the parsing between the formats.
*
* @example
*
* $service = new MyCalculatorService();
* $soap = new \Laminas\Soap\Server($wsdlFile);
* $soap->setObject(new \Laminas\Soap\Server\DocumentLiteralWrapper($service));
* $soap->handle();
*
*/
class DocumentLiteralWrapper
{
/** @var object */
protected $object;
/** @var ReflectionObject */
protected $reflection;
/**
* Pass Service object to the constructor
*
* @param object $object
*/
public function __construct($object)
{
$this->object = $object;
$this->reflection = new ReflectionObject($this->object);
}
/**
* Proxy method that does the heavy document/literal decomposing.
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, $args)
{
$this->assertOnlyOneArgument($args);
$this->assertServiceDelegateHasMethod($method);
$delegateArgs = $this->parseArguments($method, $args[0]);
$ret = call_user_func_array([$this->object, $method], $delegateArgs);
return $this->getResultMessage($method, $ret);
}
/**
* Parse the document/literal wrapper into arguments to call the real
* service.
*
* @param string $method
* @param object $document
* @return array
* @throws Exception\UnexpectedValueException
*/
protected function parseArguments($method, $document)
{
$reflMethod = $this->reflection->getMethod($method);
$params = [];
foreach ($reflMethod->getParameters() as $param) {
$params[$param->getName()] = $param;
}
$delegateArgs = [];
foreach (get_object_vars($document) as $argName => $argValue) {
if (! isset($params[$argName])) {
throw new Exception\UnexpectedValueException(sprintf(
"Received unknown argument %s which is not an argument to %s::%s",
$argName,
get_class($this->object),
$method
));
}
$delegateArgs[$params[$argName]->getPosition()] = $argValue;
}
return $delegateArgs;
}
/**
* Returns result message content
*
* @param string $method
* @param mixed $ret
* @return array
*/
protected function getResultMessage($method, $ret)
{
return [$method . 'Result' => $ret];
}
/**
* @param string $method
* @throws Exception\BadMethodCallException
*/
protected function assertServiceDelegateHasMethod($method)
{
if (! $this->reflection->hasMethod($method)) {
throw new Exception\BadMethodCallException(sprintf(
"Method %s does not exist on delegate object %s",
$method,
get_class($this->object)
));
}
}
/**
* @param array $args
* @throws Exception\UnexpectedValueException
*/
protected function assertOnlyOneArgument(array $args)
{
if (count($args) !== 1) {
throw new Exception\UnexpectedValueException(sprintf(
"Expecting exactly one argument that is the document/literal wrapper, got %d",
count($args)
));
}
}
}
PK y)V~9} } src/Client/DotNet.phpnu ٘ setSoapVersion(SOAP_1_1);
parent::__construct($wsdl, $options);
}
// @codingStandardsIgnoreStart
/**
* Do request proxy method.
*
* @param CommonClient $client Actual SOAP client.
* @param string $request The request body.
* @param string $location The SOAP URI.
* @param string $action The SOAP action to call.
* @param int $version The SOAP version to use.
* @param int $oneWay (Optional) The number 1 if a response is not expected.
* @return string The XML SOAP response.
*/
public function _doRequest(CommonClient $client, $request, $location, $action, $version, $oneWay = null)
{
if (! $this->useNtlm) {
return parent::_doRequest(
$client,
$request,
$location,
$action,
$version,
$oneWay
);
}
$curlClient = $this->getCurlClient();
// @todo persistent connection ?
$headers = [
'Content-Type' => 'text/xml; charset=utf-8',
'Method' => 'POST',
'SOAPAction' => '"' . $action . '"',
'User-Agent' => 'PHP-SOAP-CURL',
];
$uri = new HttpUri($location);
// @todo use parent set* options for ssl certificate authorization
$curlClient
->setCurlOption(CURLOPT_HTTPAUTH, CURLAUTH_NTLM)
->setCurlOption(CURLOPT_SSL_VERIFYHOST, false)
->setCurlOption(CURLOPT_SSL_VERIFYPEER, false)
->setCurlOption(CURLOPT_USERPWD, sprintf(
'%s:%s',
$this->options['login'],
$this->options['password']
));
// Perform the cURL request and get the response
$curlClient->connect($uri->getHost(), $uri->getPort());
$curlClient->write('POST', $uri, 1.1, $headers, $request);
$response = HttpResponse::fromString($curlClient->read());
// @todo persistent connection ?
$curlClient->close();
// Save headers
$this->lastRequestHeaders = $this->flattenHeaders($headers);
$this->lastResponseHeaders = $response->getHeaders()->toString();
// Return only the XML body
return $response->getBody();
}
// @codingStandardsIgnoreEnd
/**
* Returns the cURL client that is being used.
*
* @return CurlClient
*/
public function getCurlClient()
{
if ($this->curlClient === null) {
$this->curlClient = new CurlClient();
}
return $this->curlClient;
}
/**
* Retrieve request headers.
*
* @return string Request headers.
*/
public function getLastRequestHeaders()
{
return $this->lastRequestHeaders;
}
/**
* Retrieve response headers (as string)
*
* @return string Response headers.
*/
public function getLastResponseHeaders()
{
return $this->lastResponseHeaders;
}
/**
* Sets the cURL client to use.
*
* @param CurlClient $curlClient The cURL client.
* @return self
*/
public function setCurlClient(CurlClient $curlClient)
{
$this->curlClient = $curlClient;
return $this;
}
/**
* Sets options.
*
* Allows setting options as an associative array of option => value pairs.
*
* @param array|Traversable $options Options.
* @throws InvalidArgumentException If an unsupported option is passed.
* @return self
*/
public function setOptions($options)
{
if (isset($options['authentication']) && $options['authentication'] === 'ntlm') {
$this->useNtlm = true;
unset($options['authentication']);
}
$this->options = $options;
return parent::setOptions($options);
}
// @codingStandardsIgnoreStart
/**
* Perform arguments pre-processing
*
* My be overridden in descendant classes
*
* @param array $arguments
* @return array
* @throws Exception\RuntimeException
*/
protected function _preProcessArguments($arguments)
{
if (count($arguments) > 1
|| (count($arguments) == 1 && ! is_array(reset($arguments)))
) {
throw new Exception\RuntimeException(
'.Net webservice arguments must be grouped into an array: array("a" => $a, "b" => $b, ...).'
);
}
// Do nothing
return $arguments;
}
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
/**
* Perform result pre-processing
*
* My be overridden in descendant classes
*
* @param object $result
* @return mixed
*/
protected function _preProcessResult($result)
{
$resultProperty = $this->getLastMethod() . 'Result';
if (property_exists($result, $resultProperty)) {
return $result->$resultProperty;
}
return $result;
}
// @codingStandardsIgnoreEnd
/**
* Flattens an HTTP headers array into a string.
*
* @param array $headers The headers to flatten.
* @return string The headers string.
*/
protected function flattenHeaders(array $headers)
{
$result = '';
foreach ($headers as $name => $value) {
$result .= $name . ': ' . $value . "\r\n";
}
return $result;
}
}
PK y)V e~ ~ src/Client/Common.phpnu ٘ doRequestCallback = $doRequestCallback;
parent::__construct($wsdl, $options);
}
/**
* Performs SOAP request over HTTP.
* Overridden to implement different transport layers, perform additional
* XML processing or other purpose.
*
* @param string $request
* @param string $location
* @param string $action
* @param int $version
* @param int $oneWay
* @return mixed
*/
#[ReturnTypeWillChange]
public function __doRequest($request, $location, $action, $version, $oneWay = null)
{
// ltrim is a workaround for https://bugs.php.net/bug.php?id=63780
if ($oneWay === null) {
return ($this->doRequestCallback)($this, ltrim($request), $location, $action, $version);
}
return ($this->doRequestCallback)($this, ltrim($request), $location, $action, $version, $oneWay);
}
/**
* Performs SOAP request on parent class explicitly.
* Required since PHP 8.2 due to a deprecation on call_user_func([$client, 'SoapClient::__doRequest'], ...)
*
* @internal
*
* @param string $request
* @param string $location
* @param string $action
* @param int $version
* @param null|int $oneWay
* @return mixed
*/
public function parentDoRequest($request, $location, $action, $version, $oneWay = null)
{
if ($oneWay === null) {
return parent::__doRequest($request, $location, $action, $version);
}
return parent::__doRequest($request, $location, $action, $version, $oneWay);
}
}
PK y)Vjb b src/Client/Local.phpnu ٘ server = $server;
// Use Server specified SOAP version as default
$this->setSoapVersion($server->getSoapVersion());
parent::__construct($wsdl, $options);
}
// @codingStandardsIgnoreStart
/**
* Actual "do request" method.
*
* @param Common $client
* @param string $request
* @param string $location
* @param string $action
* @param int $version
* @param int $oneWay
* @return mixed
*/
public function _doRequest(Common $client, $request, $location, $action, $version, $oneWay = null)
{
// Perform request as is
ob_start();
$this->server->handle($request);
$response = ob_get_clean();
if ($response === null || $response === '') {
$serverResponse = $this->server->getResponse();
if ($serverResponse !== null) {
$response = $serverResponse;
}
}
return $response;
}
// @codingStandardsIgnoreEnd
}
PK y)V0x x
mkdocs.ymlnu ٘ docs_dir: doc/book
site_dir: doc/html
nav:
- Home: index.md
- Reference:
- Servers: server.md
- Clients: client.md
- "WSDL Parsing and Generation": wsdl.md
- "WSDL AutoDiscovery": auto-discovery.md
site_name: laminas-soap
site_description: laminas-soap
repo_url: 'https://github.com/laminas/laminas-soap'
extra:
project: Components
PK y)Vʨ phpcs.xml.distnu ٘
Create, serve, and access SOAP applications, and parse and generate WSDL.
$ composer require laminas/laminas-soap