package module
Version: v1.3.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 10 Imported by: 0


Go Soap Build Status GoDoc Go Report Card codecov

package to help with SOAP integrations (client)

go get github.com/tiaguinho/gosoap
package main

import (

type GetGeoIPResponse struct {
	GetGeoIPResult GetGeoIPResult

type GetGeoIPResult struct {
	ReturnCode        string
	IP                string
	ReturnCodeDetails string
	CountryName       string
	CountryCode       string

var (
	r GetGeoIPResponse

func main() {
	soap, err := gosoap.SoapClient("http://www.webservicex.net/geoipservice.asmx?WSDL")
	if err != nil {
		fmt.Errorf("error not expected: %s", err)

	params := gosoap.Params{
		"IPAddress": "",

	err = soap.Call("GetGeoIP", params)
	if err != nil {
		fmt.Errorf("error in soap call: %s", err)

	if r.GetGeoIPResult.CountryCode != "USA" {
		fmt.Errorf("error: %+v", r)




This section is empty.


This section is empty.


This section is empty.


type Attributes added in v1.3.1

type Attributes struct {
	XMLName xml.Name `xml:Attribute"`

	Attribute string `xml:",chardata"`
	// contains filtered or unexported fields

type Client

type Client struct {
	HttpClient   *http.Client
	WSDL         string
	URL          string
	Method       string
	SoapAction   string
	Params       Params
	HeaderName   string
	HeaderParams HeaderParams
	Definitions  *wsdlDefinitions
	Body         []byte
	Header       []byte
	Username     string
	Password     string
	// contains filtered or unexported fields

Client struct hold all the informations about WSDL, request and response of the server

func SoapClient

func SoapClient(wsdl string) (*Client, error)

SoapClient return new *Client to handle the requests with the WSDL

func (*Client) Call

func (c *Client) Call(m string, p Params, h HeaderParams) (err error)

Call call's the method m with Params p

func (*Client) GetLastRequest added in v1.2.0

func (c *Client) GetLastRequest() []byte

GetLastRequest returns the last request

func (Client) MarshalXML

func (c Client) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

MarshalXML envelope the body and encode to xml

func (*Client) Unmarshal

func (c *Client) Unmarshal(v interface{}) error

Unmarshal get the body and unmarshal into the interface

type Fault added in v1.1.0

type Fault struct {
	Code        string `xml:"faultcode"`
	Description string `xml:"faultstring"`
	Detail      string `xml:"detail"`

Fault response

type HeaderParams added in v1.2.0

type HeaderParams map[string]map[string]string

HeaderParams holds params specific to the header

type Params

type Params map[string]interface{}

Params type is used to set the params in soap request

type SoapBody

type SoapBody struct {
	XMLName  struct{} `xml:"Body"`
	Contents []byte   `xml:",innerxml"`

SoapBody struct

type SoapEnvelope

type SoapEnvelope struct {
	XMLName struct{} `xml:"Envelope"`
	Header  SoapHeader
	Body    SoapBody

SoapEnvelope struct

type SoapHeader added in v1.2.0

type SoapHeader struct {
	XMLName  struct{} `xml:"Header"`
	Contents []byte   `xml:",innerxml"`

SoapHeader struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL