bet365 / soap

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

I get this issue when trying to generate a server module from WSDL #41

Open SserwangaV opened 6 years ago

SserwangaV commented 6 years ago

Select a prefix for URI https://example.com./service.wsdl 1: No prefix 2: P0 3: Specify a custom prefix Select a number: 2 ** exception error: no case clause matching false in function erlsom_lib:getTypeFromElement/2 (src/erlsom_lib.erl, line 1046) in call from soap_parse_wsdl:type_for_part/2 (src/soap_parse_wsdl.erl, line 422) in call from soap_parse_wsdl:'-type_for_message/3-lc$^0/1-0-'/2 (src/soap_parse_wsdl.erl, line 408) in call from soap_parse_wsdl:process_op/3 (src/soap_parse_wsdl.erl, line 385) in call from soap_parse_wsdl:'-process_ops/3-lc$^0/1-0-'/4 (src/soap_parse_wsdl.erl, line 377) in call from soap_parse_wsdl:get_ops_from_port_type/2 (src/soap_parse_wsdl.erl, line 359) in call from soap_parse_wsdl:get_ops_from_binding/2 (src/soap_parse_wsdl.erl, line 287) in call from soap_parse_wsdl:get_operations/2 (src/soap_parse_wsdl.erl, line 254)

willemdj commented 6 years ago

If you can share the WSDL, I can have a look.

SserwangaV commented 6 years ago

@willemdj This is the WSDL <?xml version="1.0" encoding="utf-8"?>

willemdj commented 6 years ago

This does not look like a valid WSDL to me. There seem to be quite a few < and > characters missing. For example I assume that wsdl:types on the second line should be .

Op wo 20 jun. 2018 om 08:09 schreef dotsiadia notifications@github.com:

@willemdj https://github.com/willemdj This is the WSDL

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="https://example.com/bankservice?wsdl"> wsdl:types <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace=" https://example.com/bankservice?wsdl" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="commitResponseSchool" type="tns:commitResponseSchool"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="bankingDetail" type="tns:bankingDetail"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="serviceFee" type="tns:serviceFee"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="enquireResponseSchool" type="tns:enquireResponseSchool"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="enquireRequestSchool" type="tns:enquireRequestSchool"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="enquireResponseScholar" type="tns:enquireResponseScholar"/> <xsd:element xmlns:tns="https://example.com/bankservice?wsdl" name="enquireRequestScholar" type="tns:enquireRequestScholar"/>

xsd:sequence xsd:sequence xsd:sequence xsd:sequence xsd:sequence xsd:sequence xsd:sequence wsdl:input wsdl:output wsdl:input wsdl:output wsdl:input wsdl:output wsdl:input wsdl:output — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .
SserwangaV commented 6 years ago

@willemdj I generated that WSDL from the Erlang header file "bankservice.hrl" below using soap:erlang2wsdl("bankservice.hrl", "bankservice", "https://example.com", [{target_namespace, "https://example.com/bankservice?wsdl"}]). Please if there is anything I'm not doing properly from the .hrl file let me know. Thank you.

-spec enquireRequestScholar(Parsed_body::#enquireRequestScholar{}, Soap_req::soap:soap_req(), State::soap:soap_handler_state()) -> soap:soap_handler_response(enquireResponseScholar()).

-spec commitRequestScholar(Parsed_body::#commitRequestScholar{}, Soap_req::soap:soap_req(), State::soap:soap_handler_state()) -> soap:soap_handler_response(commitResponseScholar()).

-spec enquireRequestSchool(Parsed_body::#enquireRequestSchool{}, Soap_req::soap:soap_req(), State::soap:soap_handler_state()) -> soap:soap_handler_response(enquireResponseSchool()).

-spec commitRequestSchool(Parsed_body::#commitRequestSchool{}, Soap_req::soap:soap_req(), State::soap:soap_handler_state()) -> soap:soap_handler_response(commitResponseSchool()).

-record(enquireRequestScholar, { scholarId :: string(), schoolId :: string(), bankCode :: string(), agentCode :: string(), requestSignature :: string()}).

-type enquireRequestScholar() :: #enquireRequestScholar{}.

-record(enquireResponseScholar, { responseStatus = "" :: string(), responseStatusMeaning = "" :: string(), authCode :: string(), scholarId :: string(), schoolId :: string(), schoolName :: string(), scholarName :: string(), feesBalance :: integer(), agentCode :: string(), bankCode :: string(), bankAcCode :: string(), studySession :: string()
}).

-type enquireResponseScholar() :: #enquireResponseScholar{}.

-record(enquireRequestSchool, { schoolId = "" :: string(), agentCode = "" :: string(), requestSignature = "" :: string() }).

-type enquireRequestSchool() :: #enquireRequestSchool{}.

-record(enquireResponseSchool, { responseStatus = "" :: string(), responseStatusMeaning = "" :: string(), authCode = "" :: string(),
schoolId = "" :: string(), schoolName = "" :: string(),
studySession :: string(), schoolPays :: [#serviceFee{}]
}).

-type enquireResponseSchool() :: #enquireResponseSchool{}.

-record(serviceFee, { serviceFeeID = "" :: string(), description = "" :: string(), feeBalance = 0 :: integer(), bankingDetails :: [#bankingDetail{}] }).

-type serviceFee() :: #serviceFee{}.

-record(bankingDetail,{ bankCode = "" :: string(), bankAcCode = "" :: string() }).

-type bankingDetail() :: #bankingDetail{}.

-record(commitRequestSchool, {
authCode = "" :: string(),
schoolId = "" :: string(), transactionId = "" :: string(), serviceFeeID = "" :: string(),
amountPaid = 0 :: integer(), formOfPayment :: string(), paidBy :: string(), financialAgent :: string(), agentCode :: string(),
}).

-type commitRequestSchool() :: #commitRequestSchool{}.

-record(commitResponseSchool, { responseStatus = "" :: string(), responseStatusMeaning = "" :: string(), schoolId = "" :: string(), receiptNo = "" :: string(), transactionId = "" :: string() }).

-type commitResponseSchool() :: #commitResponseSchool{}.

willemdj commented 6 years ago

It looks like something is broken. But when I tried your command I got another error:

soap:erlang2wsdl("bankservice.hrl", "bankservice", "https://example.com", [{target_namespace, "https://example.com/bankservice?wsdl"}]). ** exception throw: {error,"Wrong Type in attribute type, expected qname, got {{qname,\"https://example.com/bankservice?wsdl\",\"bankingDetail\",\"tns\",\"tns\"},\n undefined,undefined}"} in function erlsom_write:processAttributes/5 (src/erlsom_write.erl, line 435) in call from erlsom_write:processAlternativeValue/8 (src/erlsom_write.erl, line 306) in call from erlsom_write:processElementValues/7 (src/erlsom_write.erl, line 239) in call from erlsom_write:struct2xml/6 (src/erlsom_write.erl, line 130) in call from erlsom_write:processAlternativeValue/8 (src/erlsom_write.erl, line 326) in call from erlsom_write:processElementValues/7 (src/erlsom_write.erl, line 239) in call from erlsom_write:struct2xml/6 (src/erlsom_write.erl, line 114) in call from erlsom_write:processAlternativeValue/8 (src/erlsom_write.erl, line 326)

Did you do something to work around this problem?

willemdj commented 6 years ago

Also, there are some problems with your .hrl file. commitRequestScholar and commitResponseScholar are missing. And there is a comma after the last element of #commitRequestSchool{} that should not be there.

I think that this is causing the problems that you are seeing.

SserwangaV commented 6 years ago

@willemdj I have named the .hrl to .txt such that i avoid copying the contents here bankservice.txt

When I run the function below I get the WSDL also attached here soap:erlang2wsdl("bankservice.hrl", "bankservice", "https://example.com", [{target_namespace, "https://example.com/bankservice?wsdl"}]).

WSDL (renamed bankservice_wsdl.txt from bankservice.wsdl for purposes of uploading) bankservice_wsdl.txt

But when is try generating the server, soap:wsdl2erlang("bankservice.wsdl"), I get the error above.

I have tried to provide the exact files I used that is why I have used attachments.

I'm surely stuck! Sorry for improperly copying those files before.

willemdj commented 6 years ago

There is a comma on line 123 of bankservice.txt, that is incorrect. Can you try what happens if you remove it?

SserwangaV commented 6 years ago

@willemdj Thank you guys very much! It has finally worked.