bet365 / soap

Make it easy to use SOAP from Erlang
Apache License 2.0
200 stars 74 forks source link

Not able to parse the DIDWW wsdl #9

Closed silviucpp closed 4 years ago

silviucpp commented 8 years ago

Hello,

I have the following wsdl files:

https://sandbox-api.didww.com/api2/index.php?wsdl https://api.didww.com/api2/?wsdl

But I'm not able to generate the client.

soap:wsdl2erlang("conf/did-sandbox.wsdl").
What must be generated?
1: client
2: server
3: both
Select a number: 1

Do you want to generate test stubs/skeletons?
1: no
2: yes, client only
3: yes, server only
4: yes, client and server
Select a number: 1

Which http client must be used?
1: ibrowse
2: inets
Select a number: 1
** exception error: no match of right hand side value {error,
                                                       "Include file not found (undefined)"}
     in function  soap_parse_wsdl:add_schemas/5 (src/soap_parse_wsdl.erl, line 212)
     in call from soap_parse_wsdl:parse_wsdls/3 (src/soap_parse_wsdl.erl, line 146)
     in call from soap_parse_wsdl:file/4 (src/soap_parse_wsdl.erl, line 80)
     in call from soap_parse_wsdl:get_model/2 (src/soap_parse_wsdl.erl, line 55)
     in call from soap_parse_wsdl:get_namespaces/2 (src/soap_parse_wsdl.erl, line 66)
     in call from soap:wsdl2erlang/2 (src/soap.erl, line 313)

Silviu

willemdj commented 8 years ago

Both WSDLs use SOAP encoding. The SOAP framework only supports WSDLs that are compliant with WS-I basic profile, which means that only literal encoding is supported.

neeraj9 commented 7 years ago

Is xsd:enumeration supported? I noticed that the following wsdl did not work.

<xsd:simpleType name="Color">
     <xsd:restriction base="xsd:string">
         <xsd:enumeration value="BLUE" />
         <xsd:enumeration value="RED" />
         <xsd:enumeration value="GREEN" />
      </xsd:restriction>
</xsd:simpleType>
cmullaparthi commented 7 years ago

Unfortunately, no. soap uses erlsom for processing XML, and according to https://github.com/willemdj/erlsom/blob/master/README.md#xml-schema-elements enumerations are

Ignored (all restrictions on simple types are ignored - those types are treated as ‘string’)

Not sure how difficult it would be to support it. @willemdj ?

willemdj commented 7 years ago

What do you mean exactly when you say that the "wsdl did not work"?

The enumeration should not be a reason for it not to work. You should be able to process the WSDL, and the client or server should be able to send/process requests. But you will not get a parsing error when you send/receive a value that is outside the range, so if you care about that your application will have to take care of it.

neeraj9 commented 7 years ago

What do you mean exactly when you say that the "wsdl did not work"?

There is no compilation failure for definition of simpleType per-say but the type is reported as unknown when used elsewhere.

==> Generated file SomeService_client.erl
** exception throw: {error,"Type not found",'P4:Color'}
     in function  erlsom_example_value:from_type/3 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 64)
     in call from erlsom_example_value:from_alternative/4 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 192)
     in call from erlsom_example_value:'-from_element/4-lc$^0/1-0-'/4 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 136)
     in call from erlsom_example_value:from_element/4 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 136)
     in call from erlsom_example_value:from_elements/5 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 90)
     in call from erlsom_example_value:from_type2/3 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 72)
     in call from erlsom_example_value:from_alternative/4 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 192)
     in call from erlsom_example_value:'-from_element/4-lc$^0/1-0-'/4 (_build/default/lib/erlsom/src/erlsom_example_value.erl, line 136)

The usage is as follows:

    <xsd:complexType name="someStatus">
        <xsd:sequence>
            <xsd:element name="arg0" nillable="true" type="xsd:long" />
            <xsd:element name="arg1" nillable="true" type="ns0:Color" />
        </xsd:sequence>
    </xsd:complexType>

The code for client is generated only when I get rid of usage for the simpleType (see below).

            <xsd:element name="arg1" nillable="true" type="xsd:string" />
willemdj commented 7 years ago

Can you provide a complete example? That is, the WSDL (and possibly imported files)? Something that shows how ns0 is imported/included in the WSDL, at least, because there seems to be a problem with that.

neeraj9 commented 7 years ago

Hmm.. I made this up because the WSDL is not in public domain. I'll have to spend some time to build a complete example.

cmullaparthi commented 7 years ago

@neeraj9 is this still an issue for you?

neeraj9 commented 7 years ago

@cmullaparthi The auto-gen code treats enumeration as string, but that is alright for now after I changed the WSDL a bit. Must say this project is a saviour, while helping me spread Erlang in my current organization because moving a legacy system which uses SOAP doesn't go away so easily :)

Thanks for making it open source.