bet365 / soap

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

If wsdl:part have "type" attribute and haven't "element" attribute, give error message. #4

Closed chenyu468 closed 8 years ago

chenyu468 commented 8 years ago

For example,

<wsdl:message name="getLibSysCodeResponse">
<wsdl:part name="getLibSysCode" type="xsd:string" />
</wsdl:message>

LocalPart = erlsom_lib:localName(Element), <---- throw here.

I have changed soap_parse_wsdl.erl as follows, still have error.

type_for_message(#'wsdl:definitions'{message = Messages}, Message, Model) ->
    case lists:keyfind(Message, #'wsdl:message'.name, Messages) of
        false ->
            {error, "Message " ++ Message ++ " not found"};
        #'wsdl:message'{part = Parts} when length(Parts) /= 1 ->
            {error, "Message " ++ Message ++ " does not have exactly 1 part"};
        A = #'wsdl:message'{part = [#'wsdl:part'{element = Element,type=Type}]} ->
            %% what we need is the type
            lager:debug("_381:~n\t~p",[A]),
            case Element of
                undefined ->
                    Type;
                _ ->
                    LocalPart = erlsom_lib:localName(Element),
                    Uri = erlsom_lib:getUriFromQname(Element),
                    Prefix = erlsom_lib:getPrefixFromModel(Model, Uri),
                    Element_name = case Prefix of 
                                       undefined ->
                                           LocalPart;
                                       "" ->
                                           LocalPart;
                                       _ -> 
                                           Prefix ++ ":" ++ LocalPart
                                   end,
                    type_for_element(list_to_atom(Element_name), Model)                    
            end
    end.
2016-04-30 10:18:59.993 [debug] |erlsom|erlsom_example_value|from_type|63|Undefined|Undefined|Undefined|Undefined|Undefined|Undefined|Undefined|_62:
        {qname,"http://www.w3.org/2001/XMLSchema","string","xsd","xsd"}
        2
        [{type,'_document',sequence,[{el,[],1,1,undefined,2}],[],undefined,undefined,1,1,1,false,undefined}]
** exception throw: {error,"Type not found",
                           {qname,"http://www.w3.org/2001/XMLSchema","string","xsd",
                                  "xsd"}}
     in function  erlsom_example_value:from_type/3 (src/erlsom_example_value.erl, line 66)
     in call from soap_test_module:make_function/5 (src/soap_test_module.erl, line 115)
     in call from soap_test_module:'-make_functions/4-lc$^0/1-0-'/5 (src/soap_test_module.erl, line 109)
     in call from soap_test_module:from_interface/5 (src/soap_test_module.erl, line 94)
     in call from soap_compile_wsdl:file/5 (src/soap_compile_wsdl.erl, line 104)
cmullaparthi commented 8 years ago

Can you share your WSDL/XSD privately or post a cut down version which demonstrates the problem please?

chenyu468 commented 8 years ago
<?xml version="1.0" ?>
<wsdl:definitions name="opacService" targetNamespace="urn:opacService"
             xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
             xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
             xmlns:tns="urn:opacService"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
             xmlns="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
 </wsdl:types>
<wsdl:message name="getLibSysCodeRequest">
<wsdl:part name="code" type="xsd:string" />
</wsdl:message>
<wsdl:message name="getLibSysCodeResponse">
<wsdl:part name="getLibSysCode" type="xsd:string" />
</wsdl:message>
<wsdl:portType name="opacServicePort">
  <wsdl:operation name="getLibSysCode">
    <wsdl:input message="tns:getLibSysCodeRequest" />
    <wsdl:output message="tns:getLibSysCodeResponse" />
  </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="opacServiceBinding" type="tns:opacServicePort">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="getLibSysCode">
    <soap:operation soapAction="urn:opacService#opac#getLibSysCode" />
    <wsdl:input><soap:body use="encoded" namespace="urn:opacService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </wsdl:input>
    <wsdl:output>
      <soap:body use="encoded" namespace="urn:opacService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>
<wsdl:service name="opacService">
  <wsdl:documentation />
<wsdl:port name="opacServicePort" binding="tns:opacServiceBinding">
  <soap:address location="http://33.33.33.33:33/webservice/service.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

I tried to modify the soap_parse_wsdl.erl,

willemdj commented 8 years ago

The "rpc" binding style is currently not properly supported.

I'll try to fix it, but I think it will not be a trivial task. It will probably take some time to get this work done.

willemdj commented 8 years ago

After taking a closer look at the complete WSDL example that was provided I noticed that this WSDL uses the "rpc/encoded" style. This style is not supported, since it is not part of WS-I basic profile.

Even if I manage to make the rpc style work, it will only be in combination with the "literal" encoding style (rpc/literal, which is part of WS-I basic profile). So this particular WSDL will still not be acceptable.

cmullaparthi commented 8 years ago

@chenyu468 Please see if the latest changes in #6 help you by changing the WSDL style to rpc/literal. If not, there is not much we can do I'm afraid.