Tôi mới dùng golang và Soap và gặp rắc rối trong việc phân tích cú pháp xà phòng.Làm cách nào để phân tích Soap Envelope ở Golang?
1.Tôi có một thông báo Xà phòng
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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:Body>
<activationPack_completeResponse"http://tempuri.org/">
<activationPack_completeResult xsi:type="xsd:string">Active</activationPack_completeResult>
</activationPack_completeResponse>
</soap:Body>
</soap:Envelope>
Bây giờ làm thế nào tôi nên unmarshal chúng trong golang những gì cần được khai struct tôi cho thẻ Soap Envelope.
Tôi có một số cấu trúc như sau:
type MyRespEnvelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
Soap *Body
}
type Body struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Body"`
GetResponse *ActivationPack_CompleteResponse
}
type ActivationPack_CompleteResponse struct {
XMLName xml.Name `xml:"activationPack_completeResponse"`
Id string `xml:"xmlns,attr"`
MyVar string `xml:"activationPack_completeResult"`
}
Nhưng tôi nhận được lỗi như sau:
error: expected element <Envelope> in name space http://schemas.xmlsoap.org/soap/envelope/ but have soap*stopped,reason="end-stepping-range",frame={addr="0x0000000000401211",func="main.UnmarshalFirstDitto",args=[{name="data",value="\"\\nNotice: Undefined variable: area in /var/www/nusoap/dittotv.php on line 25\\n\\nNotice: Undefined variable: area in /var/www/nusoap/dittotv.php on line 27\\n\\nNotice: Undefined variable: area in /var/www/nu\"..."}],file="/media/winshare/Golang/WorkSpace/src/DittoTv/ditto.go",fullname="/media/winshare/Golang/WorkSpace/src/DittoTv/ditto.go",line="60"},thread-id="1",stopped-threads="all",core="0"
Vì vậy, một người nào đó xin vui lòng cho tôi biết làm thế nào tôi nên tuyên bố cấu trúc của tôi để tôi có thể phân tích cú pháp thông điệp xà phòng.
Bạn có chắc tài liệu bạn đang cố phân tích cú pháp thực sự là XML không? Thông báo lỗi làm cho nó có vẻ như bạn đang cố phân tích lỗi (không phải XML) từ tập lệnh PHP –
@JamesHenstridge Có tôi. Nhưng đối với kiến thức của tôi trường nào khiến bạn cảm thấy rằng php đang trả về lỗi – user2383973
Một phần của lỗi đọc 'args = [{name =" data ", value =" \ "\\ nNotice: Biến không xác định: khu vực trong/var/www/nusoap/dittotv.php trên dòng 25 \\ n ... ' –