Call web service with wsdl

jamesmcfly

New Member
Hallo,
I am trying to call a web service with wsdl : http://crm.paramountenterprise.co.id:81/ws_member.asmx?wsdl
for example: CheckMobilePhone (http://crmdev.paramountenterprise.co.id:81/ws_member.asmx?op=CheckMobilePhone)
The xml that I have generated:
----------------
<soapenv:Envelope xmlns:crm="http://crm.paramountenterprise.co.id/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<crm:CheckMobilePhone>
<crm:crm_username>saleshotel</crm:crm_username>
<crm:crm_password>paramountP@ssword1</crm:crm_password>
<crm:mobilephone>97097097405</crm:mobilephone>
</crm:CheckMobilePhone>
</soapenv:Body>
</soapenv:Envelope>
-------------------

The response I got was "Field CRM User Name is Mandatory". The username and password should be ok, but it seems that the Web Service didn't receive the input parameters.

I have also tried using SoapUI with the similar XML, and I got the right answer.

I would be glad if someone could explain what I did wrong.

Thank you
 

mollyfud

Member
Hallo,
I am trying to call a web service with wsdl : http://crm.paramountenterprise.co.id:81/ws_member.asmx?wsdl
for example: CheckMobilePhone (http://crmdev.paramountenterprise.co.id:81/ws_member.asmx?op=CheckMobilePhone)
The xml that I have generated:
----------------
<soapenv:Envelope xmlns:crm="http://crm.paramountenterprise.co.id/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<crm:CheckMobilePhone>
<crm:crm_username>saleshotel</crm:crm_username>
<crm:crm_password>paramountP@ssword1</crm:crm_password>
<crm:mobilephone>97097097405</crm:mobilephone>
</crm:CheckMobilePhone>
</soapenv:Body>
</soapenv:Envelope>
-------------------

The response I got was "Field CRM User Name is Mandatory". The username and password should be ok, but it seems that the Web Service didn't receive the input parameters.

I have also tried using SoapUI with the similar XML, and I got the right answer.

I would be glad if someone could explain what I did wrong.

Thank you

Hi Mate,
Not sure how you tried to call the webservice but if you are using OpenEdge 10 or above you should be able to do this quite easily using the WebService call out features added. Basically you feed the WSDL document to the WebService Analyser tool (bprowsdlDoc) and it will spit out webpages that explain the structure/code that you need to call the webservice. Depending on the release you are using will depend on how well the analyser will unwrap the xml into input/output parameters and possibly even datasets and temp-tables if possible (I say depending on the release as it has changed/been improved over the years from purely expecting Longchars in and out and for you to do all the heavy lifting).

I ran the wsdl through the Analyzer and got this code to run:
-------------------
DEFINE VARIABLE crm_username AS CHARACTER init "saleshotel" NO-UNDO.
DEFINE VARIABLE crm_password AS CHARACTER init "paramountP@ssword1" NO-UNDO.
DEFINE VARIABLE mobilephone AS CHARACTER init "97097097405" NO-UNDO.
DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hws_memberSoap AS HANDLE NO-UNDO.


CREATE SERVER hWebService.


hWebService:CONNECT("-WSDL 'http://crm.paramountenterprise.co.id:81/ws_member.asmx?wsdl'
-Port ws_memberSoap").

RUN ws_memberSoap SET hws_memberSoap ON hWebService.

DEFINE TEMP-TABLE CheckMobilePhoneResult NO-UNDO
NAMESPACE-URI "http://crm.paramountenterprise.co.id/"
FIELD Status1 AS CHARACTER
XML-NODE-NAME "Status"
FIELD Message1 AS CHARACTER
XML-NODE-NAME "Message" .

DEFINE DATASET CheckMobilePhoneResultDset NAMESPACE-URI "http://crm.paramountenterprise.co.id/"
XML-NODE-TYPE "HIDDEN"
FOR CheckMobilePhoneResult.


RUN CheckMobilePhone IN hws_memberSoap(INPUT crm_username, INPUT crm_password, INPUT mobilephone, OUTPUT DATASET CheckMobilePhoneResultDset).
for each CheckMobilePhoneResult:
MESSAGE status1 skip message1
VIEW-AS ALERT-BOX.
====================
(Note: simply cut and pasted (apart from having to choose a port-name) from the generated docs, hence the funny/default/silly variable names)

This called and returned an answer so I think it worked.

You can find more about calling Soap Webservices via ABL in this knowledgebase article: How to consume Web Services from 4GL?

Hope this is helps.
Molly
 

jamesmcfly

New Member
Hi!
Thank you for you answer! I didn't know that there is a tool for that.
I tried your code, but I had to change the output from this run procedure: "RUN CheckMobilePhone IN hws_memberSoap(INPUT crm_username, INPUT crm_password, INPUT mobilephone, OUTPUT DATASET CheckMobilePhoneResultDset)." into output string, so the dataset was not used anymore. I didn't exactly know why. After that, the code ran perfectly.

Thanks a lot!
 

RealHeavyDude

Well-Known Member
You probably should change it to LONGCHAR. When analysing the WSDL Progress tries to map the data types that are provided by the WebService to their corresponding ABL data types. The ProDataSet is XML and the serialization of ProDataSets to XML an de-serialization back to ProDataSet is pretty strict. Mostly it will only work when both parties are ABL. Therefore, if the WebService is not Progress it is very likely that this de-serialization suggested by the bprowsdldoc utitlity does not work. The you just get the XML and you need to parse it yourself. Since CHARACTER is limited in sice LONGCHAR might be better suited.

Heavy Regards, RealHeavyDude.
 

mollyfud

Member
It could depend on the Release of OpenEdge that you are using. The code I passed on was taken from OpenEdge 11.3.2. Earlier versions weren't as good as converting the XML from the WSDL to ABL datatypes (especially temp-tables and datasets). Sometimes, not always, but sometimes, you can take the definition of the dataset from the later version (like my example), still use LongChar as the Output parameter and then read it into the dataset the later version suggested and it works.
If you are using the earlier releases, you should run through the WSDL analyser for that release to get its output. Also considering latest releases (I know this can be tricky with upgrades and the likes) as they have the best support for understanding WSDLs and supporting a few more of the SOAP standards.

HTH
 
Top