使用soap-clients类映射函数时缺少Namespaceprefixes

时间:2015-10-05 16:58:07

标签: php soap wsdl soap-client wsdl2php

嗨,我遇到了一些类似于这个非常古老的PHP Bug的奇怪错误:

https://bugs.php.net/bug.php?id=48966

唯一区别:我正在使用php的soap-client的classmap函数。

看起来像这样:

class Client extends \SoapClient
{
//left something out here
const DOMAIN_MODEL_NAMESPACE = 'Domain\\Model\\';


/**
 * @return array
 */
private function getClassmap()
{
    return array(
        'AddressCheck' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\AddressCheckRequest',
        'AddressCheckResponse' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\AddressCheckResponse',
        'matchingAddresses' => self::DOMAIN_MODEL_NAMESPACE . 'AddressCheck\\MatchingAddresses',
        'address' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Address',
        'RequestHeader' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Header\\RequestHeader',
        'salesOrderEntry' => self::DOMAIN_MODEL_NAMESPACE . 'Common\\Header\\SalesOrderEntry'
    );
}

/**
 * @param Configuration\ConfigurationInterface $configuration
 * @param string $wsdl
 */
public function __construct($wsdl, Configuration\ConfigurationInterface $configuration)
{
    $options = array(
        'classmap' => $this->getClassmap(),
        'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
        'location' => $configuration->getServiceLocation(),
        'trace' => 1,
        'soap_version' => SOAP_1_1,
        'exceptions' => 1,
        'cache_wsdl' => 0
    );
    parent::__construct($wsdl, $options);
}
}

其他课程:

$address = new Common\Address($street, $houseNumber, $postalCode, $city);
$request = new AddressCheck\AddressCheckRequest($address);
$response = $this->soapClient->__soapCall($requestName, array($request));

这是由wsdl2PHP生成的,但后来修改了一点以适应PSR-4自动加载。

我的问题在于生成的XML请求:

应该是(由SOAPUi生成!): - >看起来像SOAP_1_1对我来说。 (正确的吗?)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices.aax2.compax.at">
    <soapenv:Header/>
    <soapenv:Body>
        <web:AddressCheck>
            <web:header>
                <web:source>1</web:source>
                <web:version>1.11</web:version>
                <web:client>1</web:client>
                <web:testing>0</web:testing>

                <web:salesOrderEntry>
                    <web:partnerId>300011489</web:partnerId>
                    <web:distributionChannelId>300000011</web:distributionChannelId>
                </web:salesOrderEntry>
            </web:header>
            <web:address>
                <web:street>SomeStreet</web:street>
                <web:houseNumber>6</web:houseNumber>
                <web:zip>66666</web:zip>
                <web:city>SomeCity</web:city>
            </web:address>
        </web:AddressCheck>
    </soapenv:Body>
</soapenv:Envelope>

是(由soap-client生成):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:ns1="http://webservices.aax2.compax.at">
<SOAP-ENV:Body>
    <ns1:AddressCheck>
        <header>
            <source>1</source>
            <version>1.11</version>
            <client>1</client>
            <testing>0</testing>
            <salespartnerData xsi:nil="true"/>
            <salesOrderEntry>
                <partnerId>300011489</partnerId>
                <distributionChannelId>300000011</distributionChannelId>
            </salesOrderEntry>
            <last_user xsi:nil="true"/>
            <timeOfCall xsi:nil="true"/>
            <clientIP xsi:nil="true"/>
            <orderContext xsi:nil="true"/>
            <scanId xsi:nil="true"/>
        </header>
        <address>
            <street>SomeStreet</street>
            <houseNumber>6</houseNumber>
            <zip>66666</zip>
            <city>SomeCity</city>
            <buildingType xsi:nil="true"/>
            <buildingPart xsi:nil="true"/>
            <buildingPartNotes xsi:nil="true"/>
            <buildingPartDetail xsi:nil="true"/>
            <floor xsi:nil="true"/>
            <notes xsi:nil="true"/>
            <noOfCorrections xsi:nil="true"/>
        </address>
    </ns1:AddressCheck>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> 

如您所见,缺少嵌套节点的前缀。 soap-client的文档非常薄,但我不想手工生成或操作XML,因为WSDL很大!

WSDL中究竟可以配置什么错误?如果您需要,我也可以提供这些信息。但不是整个WSDL。

在我看来,根本没有使用类图..(错字可能?) 但我不知道如何调试类图?!

0 个答案:

没有答案