-
Notifications
You must be signed in to change notification settings - Fork 162
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
Multiple fixes and rpc support draft #75
Conversation
travis: cannot find package "github.com/iancoleman/strcase" |
soap/client.go
Outdated
@@ -44,6 +44,7 @@ type AuthHeader struct { | |||
type Client struct { | |||
URL string // URL of the server | |||
Namespace string // SOAP Namespace | |||
TNamespace string // SOAP Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be renamed to ThisNamespace
because the t stands for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started reviewing diffs in the order you posted and then realized you already fixed some of the things I commented on, but not all.
It'd be great if you could squash your commits for a full review before this can be merged.
wsdl/types.go
Outdated
Operations []*BindingOperation `xml:"operation"` | ||
} | ||
|
||
type SOAPBinding struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a such a small diff and yet it cannot figure out the difference between Binding and SOAPBinding by just looking at it. Also this will fail golint due to exported type with no documentation.
soap/client.go
Outdated
@@ -44,6 +44,7 @@ type AuthHeader struct { | |||
type Client struct { | |||
URL string // URL of the server | |||
Namespace string // SOAP Namespace | |||
TNamespace string // SOAP Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between Namespace and TNamespace? Comments should clarify this.
main.go
Outdated
@@ -10,8 +10,8 @@ import ( | |||
"net/url" | |||
"os" | |||
|
|||
"github.com/fiorix/wsdl2go/wsdl" | |||
"github.com/fiorix/wsdl2go/wsdlgo" | |||
"github.com/Kernle32DLL/wsdl2go/wsdl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad imports will cause compilation errors.
When I fork go code I normally keep the original package path and just add origin
to the local git config pointing to my fork. And then add upstream
pointing to the fork's origin.
wsdlgo/encoder.go
Outdated
ge.needsExtPkg["github.com/fiorix/wsdl2go/soap"] = true | ||
in[0] = renameParam(in[0], "α") | ||
out[0] = renameParam(out[0], "β") | ||
ge.needsExtPkg["github.com/Kernle32DLL/wsdl2go/soap"] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will generate code that does not compile when people use the original repo.
wsdlgo/encoder.go
Outdated
Action string | ||
PortType string | ||
Name string | ||
OpName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotta run gofmt in all this code.
wsdlgo/encoder.go
Outdated
@@ -23,7 +23,8 @@ import ( | |||
"strings" | |||
"text/template" | |||
|
|||
"github.com/fiorix/wsdl2go/wsdl" | |||
"github.com/Kernle32DLL/wsdl2go/wsdl" | |||
"github.com/iancoleman/strcase" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this new dependency? iirc we currently have zero external dependencies.
CI is failing due to missing strcase package (https://travis-ci.org/fiorix/wsdl2go/jobs/320687939). In one of the reviews I questioned whether we really need to import that package vs just copy that code. We currently have zero external deps. It's such a trivial function anyway. I'd copy that code and add a comment pointing to the original repo giving credits to the author. Licenses are compatible. |
ae735ea
to
4a7bcbb
Compare
@fiorix @Fank I did implement the changes, and did a squash. Also, while updating the golden files I found and fixes a few errors I missed so far. I have no idea how to rewrite As for the encoder tests: Renewing the *.golden files actually serves quite well to demonstrate the changes. Some notworthy things to comment on:
|
Tests are failing |
I'm currently try this PR with our wsdl files and i got some type issues: File https://xbeservetest.bedirect.de/soap/wsdl/2 Generated wsdl.go: // .. cut
// Operation wrapper for Search.
// OperationSearchOut was auto-generated from WSDL.
type OperationSearchOut struct {
Return *BedirectServerSearchResult `xml:"return,omitempty" json:"return,omitempty" yaml:"return,omitempty"`
}
// Operation wrapper for Information.
// OperationInformationOut was auto-generated from WSDL.
type OperationInformationOut struct {
Return *BedirectServerInformationResult `xml:"return,omitempty" json:"return,omitempty" yaml:"return,omitempty"`
}
// .. cut
// information
func (p *soapServicePort) Information(KID string, IDSTRING string, BIPID string, VERWENDUNGSZWECK1 string, VERWENDUNGSZWECK2 string) (*BedirectServerInformationResult, error) {
α := struct {
M OperationInformationIn `xml:"tns:information"`
}{}
α.M.KID = &KID
α.M.IDSTRING = &IDSTRING
α.M.BIPID = &BIPID
α.M.VERWENDUNGSZWECK1 = &VERWENDUNGSZWECK1
α.M.VERWENDUNGSZWECK2 = &VERWENDUNGSZWECK2
γ := struct {
M OperationInformationOut `xml:"informationResponse"`
}{}
if err := p.cli.RoundTripWithAction("https://asd.bedirect.de/soap/2#information", α, &γ); err != nil {
return nil, err
}
return γ.M._return, nil
}
// search
func (p *soapServicePort) Search(KID string, IDSTRING string, FIRMENNAME_GESAMT string, ORT string, PLZ string, STRASSE_GESAMT string, TELEFON_VORWAHL string, TELEFON_RUFNUMMER string, EMAIL string, URL string, VERSION string, HR_NUMMER string, HR_ORT string, HR_TYP string, CRF string, ZCRF string, RECHTSFORM_BD_TEXT string, PRIMAERBRANCHE string, SEKUNDAERBRANCHE string, MARKENBRANCHE string, PERSON string, ID string, UMSATZSTEUER_ID string, STEUERNUMMER string, STEUERNUMMER_ELSTER string, HANDELSNAME string, Q string, VERWENDUNGSZWECK1 string, VERWENDUNGSZWECK2 string) (*BedirectServerSearchResult, error) {
α := struct {
M OperationSearchIn `xml:"tns:search"`
}{}
α.M.KID = &KID
α.M.IDSTRING = &IDSTRING
α.M.FIRMENNAME_GESAMT = &FIRMENNAME_GESAMT
α.M.ORT = &ORT
α.M.PLZ = &PLZ
α.M.STRASSE_GESAMT = &STRASSE_GESAMT
α.M.TELEFON_VORWAHL = &TELEFON_VORWAHL
α.M.TELEFON_RUFNUMMER = &TELEFON_RUFNUMMER
α.M.EMAIL = &EMAIL
α.M.URL = &URL
α.M.VERSION = &VERSION
α.M.HR_NUMMER = &HR_NUMMER
α.M.HR_ORT = &HR_ORT
α.M.HR_TYP = &HR_TYP
α.M.CRF = &CRF
α.M.ZCRF = &ZCRF
α.M.RECHTSFORM_BD_TEXT = &RECHTSFORM_BD_TEXT
α.M.PRIMAERBRANCHE = &PRIMAERBRANCHE
α.M.SEKUNDAERBRANCHE = &SEKUNDAERBRANCHE
α.M.MARKENBRANCHE = &MARKENBRANCHE
α.M.PERSON = &PERSON
α.M.ID = &ID
α.M.UMSATZSTEUER_ID = &UMSATZSTEUER_ID
α.M.STEUERNUMMER = &STEUERNUMMER
α.M.STEUERNUMMER_ELSTER = &STEUERNUMMER_ELSTER
α.M.HANDELSNAME = &HANDELSNAME
α.M.Q = &Q
α.M.VERWENDUNGSZWECK1 = &VERWENDUNGSZWECK1
α.M.VERWENDUNGSZWECK2 = &VERWENDUNGSZWECK2
γ := struct {
M OperationSearchOut `xml:"searchResponse"`
}{}
if err := p.cli.RoundTripWithAction("https://asd.bedirect.de/soap/2#search", α, &γ); err != nil {
return nil, err
}
return γ.M._return, nil
} Errors:
The file in #65 looks good. |
Thanks for trying this, @Fank. No idea where that _return is coming from. Ping @kernle32dll. |
Did a full test, with file from #65 and everything is working as expected. |
244fc94
to
fab41d1
Compare
@Fank Good catch - Fixed. This was a tough one - I added a wsdl testcase to cover this. The linked wsdl now also generates correctly (I presume). For the curious: On the bright side, trough the changes I had to make I was able to support funcs with more than one output (we don't have a test case for that, though). |
Some test cases are still failing, and validated linked wsdl above, it is now working as expected |
fab41d1
to
0d7f1d9
Compare
This fixes some issues with wsdl2go. Namely this does the following: - Allows zero-parameter functions - Allows functions with more than one parameter to work - Allow correct sending of RPC style requests - Fixes issues with keywords and casing - Fixes truncate problem on binding regeneration
0d7f1d9
to
29285d6
Compare
Hey, this is pretty good, thanks much. It'll definitely help a lot of other people to get their soap services off the ground quicker. |
@adriantam lmk if this works for you too, or if it causes any trouble :) |
return ge.genParams(req, true), nil | ||
|
||
// TODO: I had to disable this for my use case - do other use cases still work with false? | ||
return ge.genParams(req, false), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of always hard code this to false, can we make it configurable?
Hmm..it looks like the generated golden file cannot be XML encoded properly. I will create an issue request to note that |
So, after some coffee fueled coding days, I have finished all the necessary changes to make this project work for my use case. Which is RPC - as I found out rather late.
I tested this intensively with my use case, and everything seems fine. Compatibility with non-rpc is worked in, but I was unable to test this as I don't have any non-rpc server at hand to test with. I did verify however that requests and response structures are generated so specification (so they should work).
Besides rpc support this PR makes the necessary changes for functions with any number (zero and more than 2 in particular) of parameters. Functions which have more than one return value will probably not work correctly at the moment (this was broken before, but this PR makes most of the changes to get it working in the future)
So - this PR should ™ fix the following issues:
#65 "wsdl2go issues"
#74 "Soap funcs with != 1 parameter not working"
#45 "SOAP call returns empty string"
(not sure about that one, but the body looks like rpc - so it might work now)
#9 "Namespaced operations"
(I hacked support for tns - this is not finished, but should get most use-cases of the ground. Also, it can be overridden by the client just in case)
Before this gets merged, the tests need to be adjusted, and it would probably a good idea to write tests which test the generated xml for the requests. Also, this needs some intensive testing with non-rpc servers, to ensure that I did not break previously working behavior.