PHP SOAP - 元素或属性与 QName 生产不匹配:QName::=(NCName':')?NCName



我在这里看到了一些人遇到同样的问题,但是我没有找到帮助我,我的情况似乎更具体。

我的php代码:

        error_reporting( E_ALL );
        ini_set( 'display_errors', 1 );
        ini_set( 'soap.wsdl_cache_enabled',0 );
        ini_set( 'soap.wsdl_cache_ttl',0 );
        if( !class_exists('SoapClient') )
                die( "You haven't installed the PHP-Soap module." );
        $auth = array( 'Username' => 'MyUser', 'Password' => 'MyPassord' );
        $client = new SoapClient("Soap/MyWSDLFile.wsdl",
                array(
                        'trace' => 1,
                        'exception' => 0,
                )
        );
        $header = new SoapHeader( 'Soap/MyWSDLFile.wsdl',
                '"http://10.10.10.10/app/function"',
                $auth,
                false);
        $client->__setSoapHeaders( $header );

        $function = 'MY_FUNCTION';
        $dateNow = date('Y-m-d H:i:s');
        $params = array();
        $params[] = new SoapVar( '1', XSD_INT, null, null, 'Id' );
        $params[] = new SoapVar( 'My Name', XSD_STRING, null, null, 'Name' );
        $params[] = new SoapVar( 'my@email', XSD_STRING, null, null, 'Email' );
        $fill = array();
        $fill[] = new SoapVar( 'Couple Name', XSD_STRING, null, null, 'Couple' );
        $fill[] = new SoapVar( 'Child Name', XSD_STRING, null, null, 'Child' );
        $params[] = new SoapVar( $fill, SOAP_ENC_OBJECT, null, null, 'family' );
        $out = new SoapVar( $params, SOAP_ENC_OBJECT) ;
        $result = $client->RX_UPLOAD_CONVITE_EXPOSITOR( $out );
    var_dump( $result );
} catch ( SoapFault $e ) {
        echo $client->__getLastRequest() . "<br><br>";
        echo '<pre>'; print_r($e); echo '</pre>';
}

当被调用时,我得到了错误:

[previous:Exception:private] => 
    [faultstring] => PeopleSoftServiceListeningConnector:HTTPRequest : SAXException occured while parsing the SOAP Document. SAXExceptionMessage : Element or attribute do not match QName production: QName::=(NCName':')?NCName. 
    [faultcode] => SOAP-ENV:Server
    [detail] => stdClass Object
        (
            [IBResponse] => stdClass Object
                (
                    [DefaultTitle] => Integration Broker Response
                    [StatusCode] => 20
                    [MessageID] => 10201
                    [DefaultMessage] => Integration Gateway failed while processing the message
                )
        )

和我从_getlastrequest()获得的XML是:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://10.10.10.10/app/function" xmlns:ns2="Soap/MyWSDLFile.wsdl">
        <SOAP-ENV:Header>
                <ns2:"http://10.10.10.10/app/function">
                        <item>
                                <key>Username</key>
                                <value>portal.user</value>
                        </item>
                        <item>
                                <key>Password</key>
                                <value>portal.user</value>
                        </item>
                </ns2:"http://10.10.10.10/app/function">
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
                <ns1:function>
                        <Id>1</Id>
                        <Name>My Name</Name>
                        <Email>my@email</Email>
                        <family>
                                <Couple>Couple Name</Couple>
                                <Child>Child Name</Child>
                        </family>
                </ns1:function>
        </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我知道它有效的XML是因为在Soapui中进行了测试:

<?xml version="1.0"?>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://10.10.10.10/app/function" xmlns="http://10.10.10.10/app/function" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="FunctionRequest" type="FUNCTION_REQUEST_TYPE"/>
        <xsd:complexType name="FUNCTION_REQUEST_TYPE">
                <xsd:sequence>
                        <xsd:element name="Id" type="xsd:int"/>
                        <xsd:element name="Name" type="xsd:string"/>
                        <xsd:element name="Email" type="xsd:string"/>
                        <xsd:element name="Family" type="FAMILY_TYPE"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="FAMILY_TYPE">
                <xsd:sequence>
                        <xsd:element maxOccurs="10" name="Relatives" type="RELATIVE_TYPE"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="RELATIVE_TYPE">
                <xsd:sequence>
                        <xsd:element name="Couple" type="xsd:string"/>
                        <xsd:element name="Child" type="xsd:string"/>
                </xsd:sequence>
        </xsd:complexType>
</xsd:schema>

我简化了XML,因为它更大(所有字符串或int类型),但是所有复杂的部分都在那里。

我不知道为什么来自PHP的XML与Soapui有如此不同,但肯定是我做错了的事情。

有人可以给出一个线索,说明我该怎么办或如何将PHP XML固定为相等的soapui xml?

问题是我的服务器需要以正确的方式具有WS安全性,由于某种原因,它丢失了并提供了不准确的错误信息。

我找到了以下方式进行的方法:

使用PHP连接到WS安全保护的Web服务

最好的答案不是被接受的答案。