Reputation: 4620
I am invoking methods of WSDL in Progress Openedge. So far i don't have problems invoking "GET" methods where i just need to pass password. The problem is when i need to use "SET" methods which needs password + some data stored in temp-tables. So far i have searched and found nothing that could help me. Below is code which works for calling GET methods.
DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hServiceSoap AS HANDLE NO-UNDO.
DEFINE VARIABLE symbol AS CHARACTER NO-UNDO.
DEFINE VARIABLE resp AS CHARACTER NO-UNDO.
define variable xmlCHar as longchar no-undo.
CREATE SERVER hWebService.
hWebService:CONNECT("-WSDL 'url_of_my_wsdl'").
IF NOT hWebService:CONNECTED() THEN DO:
MESSAGE "SERVER: " SKIP "url_of_my_wsdl" SKIP
"is not connected"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.
END.
RUN GET_smth_or_SET_smth SET hServiceSoap ON hWebService.
IF NOT VALID-HANDLE(hServiceSoap) THEN DO:
MESSAGE "PortType: " VALID-HANDLE(hServiceSoap) " is not valid"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
RETURN.
END.
/* password/key */
symbol = "1234asasdas".
RUN SetERPSavedStatus IN hServiceSoap(INPUT symbol, OUTPUT resp).
IF ERROR-STATUS:ERROR THEN DO:
DEFINE VARIABLE iCnt AS INTEGER NO-UNDO.
DO iCnt = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE ERROR-STATUS:GET-MESSAGE(iCnt)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
IF VALID-HANDLE(ERROR-STATUS:ERROR-OBJECT-DETAIL) THEN DO:
DEFINE VARIABLE hXML AS HANDLE NO-UNDO.
DEFINE VARIABLE mDoc AS MEMPTR NO-UNDO.
CREATE X-DOCUMENT hXML.
hXML:LOAD('LONGCHAR', ERROR-STATUS:ERROR-OBJECT-DETAIL:SOAP-FAULT-DETAIL:GET-SERIALIZED(), FALSE).
hXML:SAVE("memptr", mDoc).
MESSAGE "Fault Code : " ERROR-STATUS:ERROR-OBJECT-DETAIL:SOAP-FAULT-CODE SKIP
"Fault String: " ERROR-STATUS:ERROR-OBJECT-DETAIL:SOAP-FAULT-STRING SKIP
"Fault Actor : " ERROR-STATUS:ERROR-OBJECT-DETAIL:SOAP-FAULT-ACTOR SKIP
"Error Type : " ERROR-STATUS:ERROR-OBJECT-DETAIL:TYPE SKIP SKIP
"Fault Detail: " SKIP GET-STRING(mDoc,1)
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
END.
/* display of respond*/
MESSAGE resp
VIEW-AS ALERT-BOX INFO BUTTONS OK.
DELETE OBJECT hServiceSoap.
hWebService:DISCONNECT().
DELETE OBJECT hWebService.
What do i need to change/improve to send with my password data in temp table? When i run this code for GET methods, it works. When i use it for SET methods then i get message
Any help would be nice.
UPDATE
I changed code from
RUN SetERPSavedStatus IN hServiceSoap(INPUT symbol, OUTPUT resp)
to
RUN SetERPSavedStatus IN hServiceSoap(INPUT symbol, INPUT param, OUTPUT resp)
since i realized that that method have 2 input parameters, 1st is string, 2nd is string-array. And now the error is
UPDATE 2
Input params are next (WSDL)
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="key" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ids" type="tns:ArrayOfInt"/>
</s:sequence>
Ouput response is
<s:element minOccurs="0" maxOccurs="1" name="Result" type="tns:ArrayOfInt"/>
In Progress, i have also 3 params (2 input and 1 output). Tried to combine with types of string/integer/handle and nothing works. Still same error. I tried to test method in Boomerang and it works there, so it's not the problem about the method.
In this app i call this method with request
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/" xmlns:izv="http://link...">
<x:Header/>
<x:Body>
<izv:nameOfMethod>
<izv:key>123abcdwqsad112312</izv:key>
<izv:ids>
<izv:int>1</izv:int>
<izv:int>2</izv:int>
<izv:int>3</izv:int>
<izv:int>3108</izv:int>
<izv:int>5</izv:int>
<izv:int>6</izv:int>
<izv:int>7</izv:int>
<izv:int>3070</izv:int>
<izv:int>8</izv:int>
</izv:ids>
</izv:nameOfMethod>
</x:Body>
</x:Envelope>
Response of that request is below
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<nameOfMethodResponse xmlns="http://link...">
<nameOfMethodResult>
<int>0</int>
<int>0</int>
<int>0</int>
<int>1</int>
<int>0</int>
<int>0</int>
<int>0</int>
<int>1</int>
<int>0</int>
</nameOfMethodResult>
</nameOfMethodResponse>
</soap:Body>
</soap:Envelope>
Upvotes: 0
Views: 2450
Reputation: 8011
Generally input and output parameters when calling SOAP-based web servers are XML-documents. More often than not you will need to handle them as XML-documents withing LONGCHAR-variables and not DATASETS or TEMP-TABLES.
If calling a webservice with simple input/output you might be able to just create matching datasets or temp-tables but I would say that is rare.
First of all you need to run 'bprowsdldoc' with the provided WSDL to get a readable specification out of your webservice.
Basically:
proenv> bprowsdldoc mywsdl.wsdl [directory]
This will create a set of html-based documentation in "directory". Open up index.html and look at the 'Operation index' (it's in the upper right corner of the document).
There you will see a list of all operations provided by the wsdl. If you click one you will see the basic approach on how it's constructed and how to call it. You will also see some definitions that might or might not help you depending on how complex the input/output data is.
A basic procedure prototype might look like this:
PROCEDURE WS_WebserviceName:
DEFINE INPUT PARAMETER DATASET FOR WS_Indata.
DEFINE OUTPUT PARAMETER WS_Outdata AS LONGCHAR NO-UNDO.
END PROCEDURE.
You can see various number of inputs/outputs and of various types. But it all comes down to:
PROCEDURE WS_WebserviceName:
DEFINE INPUT PARAMETER InputData AS LONGCHAR NO-UNDO.
DEFINE OUTPUT PARAMETER OutputData AS LONGCHAR NO-UNDO.
END PROCEDURE.
(XML goes in and XML goes out.)
You need to look at the rest of the documentation (created by bprowsdldoc) or provided examples when it comes to creating the input data and parsing the output data. You should look at the XML documentation here: https://community.progress.com/community_groups/openedge_general/w/openedgegeneral/2743.openedge-11-6-product-documentation
There's basically two ways of working with XML: SAX and DOM. Read the documentation and choose what seems best to you! You could also handle xml just like text but that will most likely lead to problems!
Once your done with creating and parsing xml you will store it in longchar variables and input/output those to the webservice. Something along the way of:
RUN MyWebService IN MyWebServicePort (INPUT XMLInput, OUTPUT XmlOutput).
Best of luck!
Upvotes: 0