gpt4 book ai didi

xml - 当我用字符串 xml 调用一种方法 webservice soap 时,出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 12:37:38 24 4
gpt4 key购买 nike

当我使用字符串 xml 调用一种方法 webservice soap 时,出现以下错误:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ServiceControllerwsdl">
<x:Header/>
<x:Body>
<urn:luuPhieuNhap>
<urn:xml_phieu_nhap><?xml version=\"1.0\" encoding=\"utf-8\"?>
<CustomerSearch>
<AuthorID>$authorID</AuthorID>
<UserID>$userID</UserID>
<UserPassword>$userPassword</UserPassword>
<Email>$customerEmail</Email>
</CustomerSearch></urn:xml_phieu_nhap>
<urn:id_nhan_vien>297</urn:id_nhan_vien>
<urn:id_kho>1</urn:id_kho>
</urn:luuPhieuNhap>
</x:Body>
</x:Envelope>

我得到以下错误:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但是当我使用文本字符串时,它不会出现以下错误:

<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ServiceControllerwsdl">
<x:Header/>
<x:Body>
<urn:luuPhieuNhap>
<urn:xml_phieu_nhap>fsdfdsfd</urn:xml_phieu_nhap>
<urn:id_nhan_vien>297</urn:id_nhan_vien>
<urn:id_kho>1</urn:id_kho>
</urn:luuPhieuNhap>
</x:Body>
</x:Envelope>

我得到了很好的结果:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:ServiceControllerwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:luuPhieuNhapResponse>
<return xsi:type="xsd:integer">-1</return>
</ns1:luuPhieuNhapResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

如何解决?我在 linux 中使用 SOAP,PHP7.0,yii 框架 1.1.16。

最佳答案

您需要转义 XML 字符或更改架构以使用 xsd:any

查看此 https://stackoverflow.com/a/2349082/6371459

Unless the schema for the service describes exactly the XML you are trying to send, you have to use XML escapes to make your XML pass through the pipe as a string. <tag> instead of , etc, etc, etc.

Or, you need to change the schema to use an XML schema any particle.

您也可以使用 CDATA(不解析文本)并在服务器上重新解析 xml

 <urn:xml_phieu_nhap><![CDATA[xmlmessage]]></urn:xml_phieu_nhap>

关于xml - 当我用字符串 xml 调用一种方法 webservice soap 时,出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41210388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com