soap: aqwari.net/exp/soap Index | Examples | Files

package soap

import "aqwari.net/exp/soap"

Package soap provides types and methods for decoding a subset of SOAP 1.1. The soap package closely mirrors the standard encoding/xml package. Unmarshaling rules are identical to that of encoding/xml, with the exception that document-local links are dereferenced.

Index

Examples

Package Files

element.go soap.go

Constants

const (
    NsXSI     = "http://www.w3.org/2001/XMLSchema-instance"
    NsXSD     = "http://www.w3.org/2001/XMLSchema"
    NsSoapEnv = "http://schemas.xmlsoap.org/soap/envelope/"
    Encoding  = "http://schemas.xmlsoap.org/soap/encoding/"
)

func Flatten Uses

func Flatten(data []byte) ([]byte, error)

Flatten reads XML data from a byte slice and returns a new XML document where all references have been replaced with copies of the referenced data.

func NewRequest Uses

func NewRequest(url string, body io.Reader) (*http.Request, error)

NewRequest creates an http Request for use as a SOAP RPC call. The necessary SOAP headers are set.

func Parse Uses

func Parse(resp *http.Response, v interface{}) error

Parse decodes an http response into a Go value. If the http response contains a SOAP Fault, an error is returned.

func Unmarshal Uses

func Unmarshal(data []byte, v interface{}) error

Unmarshal decodes XML data into a Go value. Unmarshal behaves identically to xml.Unmarshal, with the addition that document links are dereferenced.

Code:

package main

import (
    "encoding/xml"
    "fmt"
    "log"
)

var xmlData = []byte(`<Envelope>
  <Header>
    <sessionId href="#id0" />
  </Header>
  <Body>
    <multiRef id="id0">123456</multiRef>
  </Body>
</Envelope>`)

func main() {
    var msg struct {
        XMLName xml.Name `xml:"Envelope"`
        Header  struct {
            Session string `xml:"sessionId"`
        }
    }

    if err := Unmarshal(xmlData, &msg); err != nil {
        log.Fatal(err)
    }
    fmt.Println(msg.Header.Session)
}

type Fault Uses

type Fault struct {
    XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Fault"`
    Code    string   `xml:"faultcode"`
    String  string   `xml:"faultstring"`
    Actor   string   `xml:"faultactor"`
    Detail  []byte   `xml:"faultDetail"`
}

A Fault describes a standard SOAP 1.1 Fault message.

func (*Fault) Error Uses

func (f *Fault) Error() string

Bugs

documents containing reference loops will probably kill the program. This is a security vulnerability and should be addressed before being put into production.

Package soap imports 6 packages (graph). Updated 2018-04-17. Refresh now. Tools for package owners.