Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use generated service? #77

Open
gondo opened this issue Jul 5, 2017 · 6 comments
Open

how to use generated service? #77

gondo opened this issue Jul 5, 2017 · 6 comments

Comments

@gondo
Copy link

gondo commented Jul 5, 2017

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?

@icobani
Copy link

icobani commented Feb 14, 2018

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

@chuyennm
Copy link

chuyennm commented Mar 2, 2018

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.

@kfimchenko
Copy link

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

@anjmao
Copy link
Collaborator

anjmao commented Oct 4, 2018

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.

@zaddok
Copy link

zaddok commented Apr 6, 2019

The above is out of date. See:

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

@jjorissen52
Copy link

jjorissen52 commented Nov 9, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants