wsdl2go icon indicating copy to clipboard operation
wsdl2go copied to clipboard

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

Open nlacey opened this issue 8 years ago • 13 comments

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

nlacey avatar Dec 01 '17 20:12 nlacey

Can you give an example?

fiorix avatar Dec 05 '17 11:12 fiorix

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.

nlacey avatar Dec 21 '17 18:12 nlacey

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

fiorix avatar Dec 22 '17 14:12 fiorix

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!

nlacey avatar Dec 26 '17 14:12 nlacey

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

fiorix avatar Dec 29 '17 18:12 fiorix

Should be good now.

fiorix avatar Dec 29 '17 22:12 fiorix

@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

warroyo avatar Feb 28 '18 16:02 warroyo

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

fiorix avatar Mar 01 '18 10:03 fiorix

@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

warroyo avatar Mar 01 '18 16:03 warroyo

PR?

fiorix avatar Mar 14 '18 11:03 fiorix

@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 avatar Oct 03 '22 02:10 prologic

#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 avatar Oct 03 '22 02:10 prologic

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

  • https://github.com/droyo/go-xml

prologic avatar Oct 03 '22 02:10 prologic