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

Bug/single client #158

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ myservice
build
.DS_Store
dist
release
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# WSDL to Go
## FACTRY fork
This Factry fork fixes a couple of issues with the original gowsdl:
* enables proper autentication with Navision - using ntlsm
* custom datetime handling, to properly parse Dates (yyyy-mm-dd)

## Original readme


[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hooklift/gowsdl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![GoDoc](https://godoc.org/github.com/hooklift/gowsdl?status.svg)](https://godoc.org/github.com/hooklift/gowsdl)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gowsdl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import (
"log"
"os"

gen "github.com/hooklift/gowsdl"
gen "github.com/factrylabs/gowsdl"
)

// Version is initialized in compilation time by go build.
Expand Down
4 changes: 2 additions & 2 deletions example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"log"
"time"

"github.com/hooklift/gowsdl/example/gen"
"github.com/hooklift/gowsdl/soap"
"github.com/factrylabs/gowsdl/example/gen"
"github.com/factrylabs/gowsdl/soap"
)

func ExampleBasicUsage() {
Expand Down
2 changes: 1 addition & 1 deletion example/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/xml"
"time"

"github.com/hooklift/gowsdl/soap"
"github.com/factrylabs/gowsdl/soap"
)

// against "unused imports"
Expand Down
1 change: 0 additions & 1 deletion go.mod

This file was deleted.

9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4 h1:pSm8mp0T2OH2CPmPDPtwHPr3VAQaOwVF/JbllOPP4xA=
github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM=
golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
6 changes: 3 additions & 3 deletions gowsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ var xsd2GoTypes = map[string]string{
"byte": "int8",
"long": "int64",
"boolean": "bool",
"datetime": "time.Time",
"date": "time.Time",
"time": "time.Time",
"datetime": "*CustomTimestamp",
"date": "*CustomTimestamp",
"time": "*CustomTimestamp",
"base64binary": "[]byte",
"hexbinary": "[]byte",
"unsignedint": "uint32",
Expand Down
48 changes: 47 additions & 1 deletion header_tmpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "gowsdl",
"version": "0.4.0",
"description": "[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hooklift/gowsdl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![GoDoc](https://godoc.org/github.com/hooklift/gowsdl?status.svg)](https://godoc.org/github.com/hooklift/gowsdl) [![Build Status](https://travis-ci.org/hooklift/gowsdl.svg?branch=master)](https://travis-ci.org/hooklift/gowsdl)",
"main": "index.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"pkg:linux": "env GOOS=linux GOARCH=amd64 go build -o ./release/$npm_package_name\\_v$npm_package_version\\_linux-x64 ./cmd/gowsdl/*.go"
},
"repository": {
"type": "git",
"url": "git+https://github.com/factrylabs/gowsdl.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/factrylabs/gowsdl/issues"
},
"homepage": "https://github.com/factrylabs/gowsdl#readme"
}
38 changes: 18 additions & 20 deletions soap/soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"crypto/tls"
"encoding/xml"
"io/ioutil"
"net"
"net/http"
"time"

ntlmssp "github.com/Azure/go-ntlmssp"
)

type SOAPEnvelope struct {
Expand Down Expand Up @@ -218,9 +219,10 @@ func WithHTTPHeaders(headers map[string]string) Option {

// Client is soap client
type Client struct {
url string
opts *options
headers []interface{}
url string
opts *options
headers []interface{}
httpClient HTTPClient
}

// HTTPClient is a client which can make HTTP requests
Expand All @@ -235,9 +237,16 @@ func NewClient(url string, opt ...Option) *Client {
for _, o := range opt {
o(&opts)
}
client := &http.Client{
Timeout: time.Minute * 2,
Transport: ntlmssp.Negotiator{
RoundTripper: &http.Transport{},
},
}
return &Client{
url: url,
opts: &opts,
url: url,
opts: &opts,
httpClient: client,
}
}

Expand Down Expand Up @@ -283,21 +292,10 @@ func (s *Client) Call(soapAction string, request, response interface{}) error {
req.Header.Set(k, v)
}
}
req.Close = true

client := s.opts.client
if client == nil {
tr := &http.Transport{
TLSClientConfig: s.opts.tlsCfg,
Dial: func(network, addr string) (net.Conn, error) {
return net.DialTimeout(network, addr, s.opts.timeout)
},
TLSHandshakeTimeout: s.opts.tlshshaketimeout,
}
client = &http.Client{Timeout: s.opts.contimeout, Transport: tr}
}

res, err := client.Do(req)
defer req.Body.Close()

res, err := s.httpClient.Do(req)
if err != nil {
return err
}
Expand Down