fiorix / wsdl2go

Command line tool to generate Go code from WSDL for SOAP XML services
Other
449 stars 158 forks source link

'-' within schema causes invalid stuct name to be created '-' can't be within struct name #47

Open nlacey opened 6 years ago

nlacey commented 6 years ago

injested wsdl files with - in there field name, In order to get the program to create the go code, I needed to go through encoder.go and add string.Replace on '-' with "" one the various tag fields

fiorix commented 6 years ago

Can you give an example?

nlacey commented 6 years ago

I'm sorry for how long this took me. If you replace nick-name with nickname, in the included file, the problem will work.

problem_example_wsdl.txt

I messed around wtih wsdlgo/encoder.go so struct names wouldn't include the '-' character, which allowed your code to run.

fiorix commented 6 years ago

Alright, so this is mainly about removing - from function names and variables but keeping them in the XML tags? PR?

nlacey commented 6 years ago

correct, attached export.go that worked with example file, encoder.txt

created cleanString function (currently removes '-' and ' ') Not sure how complete it is, but it was able to convert the previously attached file thanks!

fiorix commented 6 years ago

Yeah we need to fix this. @flavioayra just reported the same problem, finding "-" and "." in type/op names.

fiorix commented 6 years ago

Should be good now.

warroyo commented 6 years ago

@fiorix i am still seeing this issue with "." in the name, was this added to fix "." or just "-"

here is an example file. it is from the F5 Networks WSDL. unfortunately they use "." all over the place.

for refrence here is the error

 generated bad code: 1182:16: expected type, found '.' (and 1 more errors)
    1180
 1181   // management.ResourceRecordPortType implements the ManagementResourceRecordPortType interface.
 1182   type management.ResourceRecordPortType struct {
 1183       cli *soap.Client
 1184   }
 1185

wsdl.txt

fiorix commented 6 years ago

I think I missed the "." in the regex that makes it a valid Go symbol: https://github.com/fiorix/wsdl2go/blob/88777812a5daba043066aae0e7dd72b0a6343f98/wsdlgo/encoder.go#L1243

warroyo commented 6 years ago

@fiorix in this case the "." is actually invalid in the type name, i think that problem is that it is not using the validGoSymbol function when creating types

fiorix commented 6 years ago

PR?

prologic commented 1 year ago

@fiorix I'm also seeing this as well.

For example:

$ wsdl2go < ParseAddress.wsdsl > ParseAddr.go
2022/10/03 12:04:06 generated bad code: 3:13: expected ';', found '-'
    1   // Code generated by wsdl2go. DO NOT EDIT.
    2
    3   package plsp-public
...

This WSDL comes from: https://information.qld.gov.au/service/Addressing/ValidationService/PLSplusPublic/soap?wsdl

prologic commented 1 year ago

47 fixes a bunch of bugs I found with generating type names, method names and so on. This resolves my problem as well as the one found in this issue. I'm not happy with the code, but it generated valid Go code finally 😅

prologic commented 1 year ago

FWW I achieved much better results by using the wsdlgen cli utility found in this package: