soap php调用的问题是因为xml错误

时间:2012-10-28 19:43:24

标签: php xml soap webserver

我正在尝试向网络服务拨打肥皂以传递送货数据。这是我到目前为止发送的请求:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://weblabeling.gls-italy.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
    <env:Body>
        <ns1:AddParcel env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
        <!-- bof shipping array --->
            <XMLInfoParcel>
                <Info>
                    <SedeGls>XXXX</SedeGls>
                    <CodiceClienteGls>XXXXX</CodiceClienteGls>
                    <PasswordClienteGls>XXXXXX</PasswordClienteGls>
                    <Parcel>
                        <CodiceContrattoGls>XXXXXX</CodiceContrattoGls>
                        <RagioneSociale>XXXXXX</RagioneSociale>
                        <!-- other stuff here -->
                    </Parcel>
                </Info>
            </XMLInfoParcel>
            <!-- eof shipping array --->
        </ns1:AddParcel>
    </env:Body>
</env:Envelope>    

而不是webservice问我的是什么

    <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
      <soap12:Body>
        <AddParcel xmlns="http://weblabeling.gls-italy.com/">
          <XMLInfoParcel>string</XMLInfoParcel>
        </AddParcel>
      </soap12:Body>
    </soap12:Envelope>

我总是得到xml格式错误的响应。

有什么问题? 送货数组是正确的,完全符合要求。

提前致谢。

编辑:

以下是我如何构建xml:

//inseriamo i dati nei corretti array
$Label = array(
                'XMLInfoParcel' => array(
                'Info' => array(
                    'SedeGls' => $SedeGls,
                    'CodiceClienteGls' => $CodiceClienteGls,
                    'PasswordClienteGls' => $PasswordClienteGls,                
                    'Parcel' => array(
                                       'CodiceContrattoGls' => $cod_cont,
                                       'RagioneSociale' => $rag_soc,
                                       'Indirizzo' => $delivery_indirizzo,
                                       'Localita' => $delivery_city,
                                       'Zipcode' => $data['delivery_postcode'],
                                       'Provincia' => $data['zone_code'],
                                       'Bda' => '',
                                       'DataDocumentoTrasporto' => '',
                                       'Colli' => '1',
                                       'Incoterm' => '',
                                       'PesoReale' => '1,00',
                                       'ImportoContrassegno' => $imp_cont,
                                       'NoteSpedizione' => $data['customers_telephone'],
                                       'TipoPorto' => 'F',
                                       'Assicurazione' => $ass_ins,
                                       'PesoVolume' => '',
                                       'TipoCollo' => $tipo_collo,
                                       'FrancoAnticipata' => '',
                                       'RiferimentoCliente' => '',
                                       'NoteAggiuntive' => '',
                                       'CodiceClienteDestinatario' => '',
                                       'Email' => '',
                                       'Cellulare1' => $telefono_1,
                                       'Cellulare2' => '',
                                       'ServiziAccessori' => '',
                                       'ModalitaIncasso' => $mod_inc    
                                      ),),),                                
                );


$dom = new DOMDocumentExt('1.0', 'utf-8');              
$chiamta = $dom->loadArray($Label);
$dudy = $dom->saveXML();

@Iserni我把---&gt;只有在这里,这不是我的代码,我要测试在线工具,我真的没有看到错误。

我仍然得到xml格式的错误,还有其他线索吗?

编辑:

我刚注意到我的请求有:

<ns1:AddParcel env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

虽然要求是:

<AddParcel xmlns="http://weblabeling.gls-italy.com/">

所以我也注意到信封中有一些与命名空间不同的东西。 这可能是问题吗?

WSDL似乎无法在gls服务器上运行,但它们没有提供有关它的文档中的任何信息。

编辑:

也许我很笨,但这是请求xml架构:

schema

所以我现在应该放更多的空格? 你怎么看?如果是这样的话?

1 个答案:

答案 0 :(得分:2)

您的XML中有三个错误,但您可以使用xmllint(也是online)轻松找到它们(以及未来的错误)。

基本上,您的XML评论应该以{{1​​}}而不是-->结束,您应该检查标记的开启/关闭。

此外,该请求适用于--->,但这不是您发送的内容......?