gowsdl
gowsdl copied to clipboard
how to use generated service?
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?
It is very important i can not find any sample anywhere?
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.
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..
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.
The above is out of date. See:
https://github.com/hooklift/gowsdl/blob/master/example/example.go
@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.