banjun/WSDL2Swift

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

Bathilde opened this issue · 2 comments

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.

@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?

There need some work for communicating that service.

  • add Double and Float to typeMap and conform protocol as built-in types (trivial work)
  • add SOAPAction: "" or whatever to request HTTP header. Some service work without this. the issued service does not seem to respond without this header. (trival work, but some integration test needed for other services)
  • add namespace handling to unify targetNameSpace. in this case, tns, ns0, ns1 and ax21 should be treated as the same namespace. currently not handled by WSDL2Swift.
  • add namespace for additional namespace to SOAPRequest generation. in this case, xsd namespace is separated from the target name space tns. xmlns:tns="http://wsiv.ratp.fr" and xmlns:tns2="http://wsiv.ratp.fr/xsd".
  • add type for empty part message. in this case, struct Wsiv_getVersion should be generated with no properties. this required due to current request dispatches by Swift method overloads. I think tough work is to get exact getVersion, not the getVersionRequest.

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