gosoap

package module
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 10 Imported by: 0

README

Go Soap Build Status GoDoc Go Report Card codecov

package to help with SOAP integrations (client)

Install
go get github.com/tiaguinho/gosoap
Example
package main

import (
	"github.com/tiaguinho/gosoap"
	"fmt"
)

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": "8.8.8.8",
	}

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func XmlUnmarshal added in v1.3.1

func XmlUnmarshal(r io.Reader, v interface{}) error

Поддержка кодировок кроме utf8 https://stackoverflow.com/questions/6002619/unmarshal-an-iso-8859-1-xml-input-in-go

Types

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 Helper added in v1.3.3

type Helper struct {
	// contains filtered or unexported fields
}

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

func NewHelper added in v1.3.3

func NewHelper(wsdlURL string) (*Helper, error)

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

func (*Helper) CheckError added in v1.3.3

func (c *Helper) CheckError(data []byte) error

func (*Helper) FillFastRequest added in v1.3.3

func (c *Helper) FillFastRequest(req *fasthttp.Request, method string, params XMLMarshaller, headerName string, headerParams XMLMarshaller) error

Заполняет поля fasthttp.Request

type Param added in v1.3.3

type Param struct {
	K, V string
}

func (*Param) GetV added in v1.3.3

func (o *Param) GetV() string

type Params

type Params []Param

Params type is used to set the params in soap request

func (*Params) Get added in v1.3.3

func (ps *Params) Get(K string) (string, bool)

func (*Params) GetXML added in v1.3.4

func (o *Params) GetXML() ([]byte, error)

func (*Params) Set added in v1.3.3

func (ps *Params) Set(K, V string)

type RawToken added in v1.3.3

type RawToken []byte

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.3.1

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

SoapHeader struct

type XMLMarshaller added in v1.3.4

type XMLMarshaller interface {
	GetXML() ([]byte, error)
}

Jump to

Keyboard shortcuts

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