soap: Index | Examples | Files

package soap

import ""

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.



Package Files

element.go soap.go


const (
    NsXSI     = ""
    NsXSD     = ""
    NsSoapEnv = ""
    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.


package main

import (

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

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

    if err := Unmarshal(xmlData, &msg); err != nil {

type Fault Uses

type Fault struct {
    XMLName xml.Name `xml:" 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


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 2019-10-02. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).