复杂类型不在WSDL PHP中映射

时间:2012-08-15 04:16:41

标签: php soap wsdl complextype

我是WSDL的新手,遇到了复杂类型的问题。基本上它就好像输入消息没有使用complexType作为输入消息的类型。

我故意拼错了输出消息上的命名空间,因此我可以返回传递给服务器的内容。返回的是客户端代码中发送的所有内容。我所期望的,如果肥皂可以投射任何类型以匹配WSDL并剥离任何额外内容,或者至少抛出错误。

我的代码是否有问题,或者我对输入应该发生什么有所了解?

提前致谢。

客户端:

ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient('http://example.com/Service_v1.wsdl', array("trace" => 1));

$request['UAT'] = 'fdgdfg';
$request['TemplateID'] = '236';
$request['To'] = 'email@address.com';
$request['From'] = 'mail@address.com';
$request['Org'] = 'PPRG';
$request['Order'] = 'order_number';
$request['Fake'] = 'fakefake';
$request['DeliverTimestamp'] = '2012-09-01 00:00:00';


var_dump($client->newEmail($request));

echo "<br><br><br>" .htmlentities($client->__getLastRequest() );

服务器:

ini_set("soap.wsdl_cache_enabled", "0");


class CreateEmail {

function newEmail($request) {
    return array('Status' => $request, 'ReferenceID' => 123);
    }
}


$server = new SoapServer("Service_v1.wsdl");

$server->setClass("CreateEmail");

$server->handle();

WSDL:

<definitions name="Service_v1"  targetNamespace="http://example.com/Service_v1" xmlns="http://schemas.xmlsoap.org/wsdl/"    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"  xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"   xmlns:xsd="http://www.w3.org/2001/XMLSchema">


<wsdl:types>
    <xsd:element name="TransactionDetail">
        <xsd:complexType>
            <xsd:complexContent mixed="true">
                <xsd:restriction base="xsd:anyType">                    
                    <xsd:element name="UAT" type="xsd:boolean" minOccurs="0" maxOccurs="1"/>
                    <xsd:element name="TemplateID" type="xsd:integer" minOccurs="1" maxOccurs="1"/>
                    <xsd:element name="To" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                    <xsd:element name="From" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                    <xsd:element name="Org" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                    <xsd:element name="Order" type="xsd:string" minOccurs="1" maxOccurs="1"/>
                    <xsd:element name="DeliverTimestamp" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
                </xsd:restriction>
            </xsd:complexContent>
        </xsd:complexType>
    </xsd:element>

</wsdl:types>

<message name="CreateEmailRequest">
    <part name="emailInfo" element="tns:TransactionDetail"/>
</message>

<message name="CreateEmailReply">
    <part name="Status" type="xs:boolean"/>
    <part name="ReferenceID" type="xsd:integer"/>
</message>

<portType name='CreateEmailPortType'>
    <operation name='newEmail'>
        <input message='tns:CreateEmailRequest'/>
        <output message='tns:CreateEmailReply'/>
    </operation>
</portType>

<binding name='CreateEmailBinding' type='tns:CreateEmailPortType'>
    <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>

    <operation name='newEmail'>
        <soap:operation soapAction='urn:xmethods-delayed-quotes#newEmail'/>
        <input>
            <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </input>

        <output>
            <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
        </output>
    </operation>
</binding>

<service name='CreateEmailService'>
  <port name='CreateEmailPort' binding='CreateEmailBinding'>
    <soap:address location='http://example.com/CreateEmail.php'/>
  </port>
</service>

</definitions>

0 个答案:

没有答案