gowsdl icon indicating copy to clipboard operation
gowsdl copied to clipboard

how to use generated service?

Open gondo opened this issue 7 years ago • 6 comments

it would be very helpful to see basic example of how to use the generated code. i am just starting with golang. i've managed to generate myservice.go and now what?

gondo avatar Jul 05 '17 08:07 gondo

It is very important i can not find any sample anywhere?

icobani avatar Feb 14 '18 13:02 icobani

Hello ,

Please help me , I have using gowsdl.exe my.wsdl to myservice.go

When i wrote the test file:

type LoginRequest struct { XMLName xml.Name xml:"http://entities login" username string xml:"username,omitempty" password string xml:"password,omitempty" partnerID string xml:"partnerID,omitempty" }

client := myservice.NewSOAPClient("MYURL service", true, nil)

req := new(LoginRequest)

req.username="gamef7"
req.password="sgrglb"
req.partnerID="gamef7"
fmt.Println(req)
res := &myservice.LoginResponse{}
if err := client.Call("", req, res); err != nil {
	panic(err)
}

Run it, then from console log:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
      <Body xmlns="http://schemas.xmlsoap.org/soap/envelope/">
          <login xmlns="http://entities"></login>
      </Body>
  </Envelope>

Why my parameter not in there? (username, password,...).

Thanks for your support.

chuyennm avatar Mar 02 '18 11:03 chuyennm

still no any examples? wow I'm trying to use service.Call("MethodName", rq, rsp) and my rsp is nil always without any error. Have no idea what is wrong..

kfimchenko avatar Jul 13 '18 08:07 kfimchenko

Example:

package integration

import (
	"do/pkg/soap"
	"fmt"
	"testing"
)

func TestSoapClient(t *testing.T) {
	url := "http://webservices/service.asmx"
	soapService := soap.NewServiceSoap(url, false, &soap.BasicAuth{})
	echoReply, err := soapService.Ping(&soap.Ping{Message: "a"})
	fmt.Println(echoReply.PingResult)
}

Replace import do/pkg/soap with your import to generated soap file.

anjmao avatar Oct 04 '18 14:10 anjmao

The above is out of date. See:

https://github.com/hooklift/gowsdl/blob/master/example/example.go

zaddok avatar Apr 06 '19 07:04 zaddok

@chuyennm

type LoginRequest struct {
    XMLName xml.Name `xml:"http://entities login"`
    Username string `xml:"username,omitempty"`
    Password string `xml:"password,omitempty"`
    PartnerID string `xml:"partnerID,omitempty"`
 }

Go uses capitalization to indicate private and public fields in structs. If a field name is not capitalized, it is private, and thus not usable by methods external to your package.

jjorissen52 avatar Nov 09 '19 09:11 jjorissen52