【发布时间】:2016-12-19 02:33:45
【问题描述】:
当我用字符串 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、PHP7.0、yii framework 1.1.16中使用SOAP。
【问题讨论】:
标签: xml linux web-services soap