gosoap

package module
v0.0.0-...-bb7c1f5 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 7 Imported by: 0

README

Go Soap Build Status GoDoc Go Report Card codecov

package to help with SOAP integrations (client)

Credits

This project is an adaptation of the github.com/tiaguinho/gosoap, to meet the specific needs of Infor Sunsystems Connect SSC

Install
go get github.com/UnionMexicanaDelNorte/soapClientGolangForSSC
Example
soap, err := gosoap.SoapClient("http://localhost:8080/connect/wsdl/SecurityProvider?wsdl","http://localhost:8080/connect/soap/SecurityProvider")
	if err != nil {
		fmt.Errorf("error not expected: %s", err)
	}
	params := gosoap.Params{
		"name": "AOK",
		"password" : "",
	}
	err = soap.Call("Authenticate", "SecurityProviderAuthenticateRequest", params)
	if err != nil {
		fmt.Errorf("error in soap call: %s", err)
	}
	vaucher := soap.GetResponse()
	fmt.Println(vaucher)
	soapJournal, err := gosoap.SoapClient("http://localhost:8080/connect/wsdl/ComponentExecutor?wsdl","http://localhost:8080/connect/soap/ComponentExecutor")
	if err != nil {
		fmt.Errorf("error not expected: %s", err)
	}

	params = gosoap.Params{
		"authentication": vaucher,
		"licensing" : "",
		"component" : "Journal",
		"method" : "Import",
		"group" : "",
		"payload" : `<SSC>
  <SunSystemsContext>
    <BusinessUnit>CEA</BusinessUnit>
    <BudgetCode>A</BudgetCode>
  </SunSystemsContext>
  <MethodContext>
    <LedgerPostingParameters>
      <JournalType>JV</JournalType>
      <PostingType>2</PostingType>
      <PostProvisional>N</PostProvisional>
      <PostToHold>N</PostToHold>
      <BalancingOptions>T2</BalancingOptions>
      <SuspenseAccount>338100</SuspenseAccount>
      <TransactionAmountAccount>338100</TransactionAmountAccount>
      <ReportingAccount>338100</ReportingAccount>
      <SupressSubstitutedMessages>N</SupressSubstitutedMessages>
      <ReportErrorsOnly>Y</ReportErrorsOnly>
    </LedgerPostingParameters>
  </MethodContext>
  <Payload>
    <Ledger>
      <Line>
        <TransactionReference>651C</TransactionReference>
        <AccountingPeriod>0052017</AccountingPeriod>
        <TransactionDate>07052017</TransactionDate>
        <AccountCode>ERROJAB01</AccountCode>
        <AnalysisCode2/>
        <AnalysisCode3>10</AnalysisCode3>
        <AnalysisCode4/>
        <AnalysisCode5/>
        <AnalysisCode6/>
        <AnalysisCode7/>
        <AnalysisCode8/>
        <AnalysisCode9/>
        <AnalysisCode10/>
        <Description>GONZALEZ ALCUDIA HUMBERTO</Description>
        <Value4Amount>3500</Value4Amount>
        <DebitCredit>D</DebitCredit>
        <Value4CurrencyCode>MXP1</Value4CurrencyCode>
        <DueDate>07052017</DueDate>
      </Line>
      <Line>
        <TransactionReference>651C</TransactionReference>
        <AccountingPeriod>0052017</AccountingPeriod>
        <TransactionDate>07052017</TransactionDate>
        <AccountCode>ERROJAB01</AccountCode>
        <AnalysisCode2/>
        <AnalysisCode3>10</AnalysisCode3>
        <AnalysisCode4/>
        <AnalysisCode5/>
        <AnalysisCode6/>
        <AnalysisCode7/>
        <AnalysisCode8/>
        <AnalysisCode9/>
        <AnalysisCode10/>
        <Description>GONZALEZ ALCUDIA HUMBERTO</Description>
        <Value4Amount>3500</Value4Amount>
        <DebitCredit>C</DebitCredit>
        <Value4CurrencyCode>MXP1</Value4CurrencyCode>
        <DueDate>07052017</DueDate>
      </Line>
    </Ledger>
  </Payload>
</SSC>
`,
	}
	err = soapJournal.Call("Execute", "ComponentExecutorExecuteRequest", params)
	if err != nil {
		fmt.Errorf("error in soap call: %s", err)
	}
	diario := soapJournal.GetResponse()
	fmt.Println(diario)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	WSDL          string
	URL           string
	Method        string
	EnvelopeTitle string
	Params        Params
	Definitions   *wsdlDefinitions
	Body          []byte
	// 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, urlSoap string) (*Client, error)

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

func (*Client) Call

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

Call call's the method m with Params p

func (*Client) GetResponse

func (c *Client) GetResponse() string

Unmarshal get the body and unmarshal into the interface

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

type Fault

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

Fault response

type Params

type Params map[string]string

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"`
	Body    SoapBody
}

SoapEnvelope struct

Jump to

Keyboard shortcuts

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