soapproxy

package module
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

README

soapproxy

A simple SOAP <-> gRPC proxy.

1. Generate the WSDL

with ./protoc-gen-wsdl:

protoc --wsdl_out=myproxy -I $GOPATH/src $GOPATH/src/unosoft.hu/ws/bruno/pb/dealer/dealer.proto

will create myproxy/dealer.wsdl and myproxy/dealer.wsdl.go.

2. Generate the Client code

with github.com/UNO-SOFT/gprcer/protoc-gen-grpcer:

protoc --grpcer_out=myproxy -I $GOPATH/src $GOPATH/src/unosoft.hu/ws/bruno/pb/dealer/dealer.proto

will create myproxy/dealer.grpcer.go, with grpc.Client implementation in it.

3. Profit!

Then use the SOAPHandler in myproxy/main.go (see ./example/example.go):

cc, err := grpcer.Connect("grpc-host:port", "ca.pem", "localhost")
if err != nil {
	log.Fatal(err)
}
http.ListenAndServe(
	":8080",
	soapproxy.SOAPHandler{Client:NewClient(cc), WSDL:soapproxy.Ungzb64(WSDLgzb64)},
)

Documentation

Index

Constants

View Source
const (
	SOAPHeader = `` /* 145-byte string literal not displayed */
	SOAPFooter = `</soapenv:Body></soapenv:Envelope>`
)

Variables

View Source
var (
	DefaultCallTimeout = time.Minute
)
View Source
var DefaultTimeout = 5 * time.Minute

Functions

func FilterEmptyTags

func FilterEmptyTags(w io.Writer, r io.Reader) error

func FindBody

func FindBody(dec *xml.Decoder) (xml.StartElement, error)

FindBody will find the first StartElement after soap:Body.

func SOAPCall added in v0.10.4

func SOAPCall(ctx context.Context, destURL, action string, reqBody string, resp interface{}, Log func(...interface{}) error) error

SOAPCall destURL with SOAPAction=action, decoding the response body into resp.

func Ungzb64

func Ungzb64(s string) string

Ungzb64 decodes-decompresses the given gzipped-base64-encoded string. Esp. useful for reading the WSDLgzb64 from protoc-gen-wsdl embedded WSDL strings.

Types

type Annotation added in v0.10.4

type Annotation struct {
	Raw      bool
	RemoveNS bool
}

type SOAPFault added in v0.10.4

type SOAPFault struct {
	XMLName xml.Name `xml:"SOAP-ENV:Fault"`
	Code    string   `xml:"faultcode,omitempty"`
	String  string   `xml:"faultstring,omitempty"`
	Actor   string   `xml:"faultactor,omitempty"`
	Detail  string   `xml:"detail>ExceptionDetail,omitempty"`
}

SOAPFault fault

type SOAPHandler

type SOAPHandler struct {
	grpcer.Client
	WSDL         string
	Log          func(keyvals ...interface{}) error
	Locations    []string
	DecodeInput  func(*string, *xml.Decoder, *xml.StartElement) (interface{}, error)
	EncodeOutput func(*xml.Encoder, interface{}) error
	DecodeHeader func(context.Context, *xml.Decoder, *xml.StartElement) (context.Context, func(context.Context, io.Writer, error) error, error)

	Timeout time.Duration
	// contains filtered or unexported fields
}

SOAPHandler is a http.Handler which proxies SOAP requests to the Client. WSDL is served on GET requests.

func (*SOAPHandler) Input added in v0.10.4

func (h *SOAPHandler) Input(name string) interface{}

func (*SOAPHandler) ServeHTTP

func (h *SOAPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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