banjun / WSDL2Swift

Pure Swift alternative to WSDL2ObjC making a SOAP request & parsing its response as defined in WSDL
MIT License
27 stars 8 forks source link

Error when generating swift classes: Unexpectedly found nil while unwrapping an Optional value #1

Open Bathilde opened 7 years ago

Bathilde commented 7 years ago

Hello, I have been using your tool to generate a few files. When I try to use the wsdl from this public website: http://www.ratp.fr/wsiv/services/Wsiv?wsdl I have an error.

fatal error: unexpectedly found nil while unwrapping an Optional value Current stack trace: 0 libswiftCore.dylib 0x000000010fb52ce0 swift_reportError + 132 1 libswiftCore.dylib 0x000000010fb70090 _swift_stdlib_reportFatalError + 61 2 libswiftCore.dylib 0x000000010f9660c0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355 3 libswiftCore.dylib 0x000000010fae2230 partial apply for (_fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never).(closure #2) + 109 4 libswiftCore.dylib 0x000000010f9660c0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 355 5 libswiftCore.dylib 0x000000010fa9a3f0 specialized _fatalErrorMessage(StaticString, StaticString, StaticString, UInt, flags : UInt32) -> Never + 96 6 WSDL2Swift 0x000000010f713ba0 static WSDLMessage.deserialize(AEXMLElement) -> WSDLMessage? + 635 7 WSDL2Swift 0x000000010f730b20 partial apply for static WSDLMessage.deserialize(AEXMLElement) -> WSDLMessage? + 20 8 WSDL2Swift 0x000000010f7141d0 thunk + 53 9 WSDL2Swift 0x000000010f7142f0 partial apply for thunk + 89 10 libswiftCore.dylib 0x000000010fa19cd0 Sequence.flatMap<A> ((A.Iterator.Element) throws -> A1?) throws -> [A1] + 632 11 WSDL2Swift 0x000000010f708030 WSDL.init(path : String) -> WSDL? + 2143 12 WSDL2Swift 0x000000010f705f60 static Core.main(out : URL, in : [String], publicMemberwiseInit : Bool) throws -> () + 666 13 WSDL2Swift 0x000000010f731d00 (closure #1) + 858 14 WSDL2Swift 0x000000010f732160 thunk + 95 15 WSDL2Swift 0x000000010f732250 partial apply for thunk + 96 16 Commander 0x000000010f7cdb70 (command<A, B, C where ...> (A, B, C, (A.ValueType, B.ValueType, C.ValueType) throws -> ()) -> CommandType).(closure #1) + 2215 17 Commander 0x000000010f7ce840 partial apply for (command<A, B, C where ...> (A, B, C, (A.ValueType, B.ValueType, C.ValueType) throws -> ()) -> CommandType).(closure #1) + 276 18 Commander 0x000000010f7ba600 AnonymousCommand.run(ArgumentParser) throws -> () + 82 19 Commander 0x000000010f7ba750 protocol witness for CommandType.run(ArgumentParser) throws -> () in conformance AnonymousCommand + 68 20 Commander 0x000000010f7bb250 CommandType.run(String?) -> Never + 1109 21 WSDL2Swift 0x000000010f731630 main + 1581 22 libdyld.dylib 0x00007fffa21f2254 start + 1

So you have any idea how I can see where the error is from? I validate the WSDL and it seems to be fine.

Thank you.

banjun commented 7 years ago

@Bathilde Thanks issuing with the example wsdl.

After first look, return self.init(name: name, part: node["part"].first!) fails for getVersionRequest, which means WSDL2Swift requires each wsdl message have at least one part. I guess WSDL2Swift should also work without part for no arguments operation. Do you know about the expected Swift code generation for getVersionRequest?

banjun commented 7 years ago

There need some work for communicating that service.

I have inspected some of this on this branch, but cannot make further changes for now. Pull Requests for this issue are still welcome. https://github.com/banjun/WSDL2Swift/tree/issue-1