我正在尝试更新我们的股票,认为 Magento API 使用 Progress 4GL (OpenEdge 10.2B)
到目前为止一切顺利,即:如果 SKU 匹配,我可以更新库存。但如果不是,它不会返回错误。
因此,我研究了 ABL 如何管理 SAOP 故障错误,并找到了一些我尝试实现的示例。但无济于事。
我的新代码如下:
DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hMage_Api_Model_Server_V2_HandlerPortType AS HANDLE NO-UNDO.
DEFINE VARIABLE username AS CHARACTER NO-UNDO.
DEFINE VARIABLE apiKey AS CHARACTER NO-UNDO.
DEFINE VARIABLE stock AS CHARACTER NO-UNDO.
DEFINE VARIABLE codigo AS CHARACTER NO-UNDO.
DEFINE VARIABLE loginReturn AS CHARACTER NO-UNDO.
DEFINE VARIABLE product AS CHARACTER NO-UNDO.
DEFINE VARIABLE data AS LONGCHAR NO-UNDO.
DEFINE VARIABLE resultado AS INTEGER NO-UNDO.
DEFINE VARIABLE SOAP-FAULT-CODE AS CHARACTER NO-UNDO.
DEFINE VARIABLE SOAP-FAULT-DETAIL AS CHARACTER NO-UNDO.
DEFINE VARIABLE iError AS INTEGER NO-UNDO.
DEFINE VARIABLE cError AS CHARACTER NO-UNDO.
DO ON ERROR UNDO, THROW:
CREATE SERVER hWebService.
/* TODO: Definir variaveis globais */
username = 'username'.
apiKey = 'password'.
hWebService:CONNECT(" -WSDL 'http://www.medicalemcasa.com/api/v2_soap?wsdl'").
RUN Mage_Api_Model_Server_V2_HandlerPortType SET hMage_Api_Model_Server_V2_HandlerPortType ON hWebService.
RUN login IN hMage_Api_Model_Server_V2_HandlerPortType(INPUT username, INPUT apiKey, OUTPUT loginReturn).
product = "100asda001a".
data = "
<data>
<qty>'250'</qty>
</data>
".
PROCEDURE catalogInventoryStockItemUpdate:
DEFINE INPUT PARAMETER data AS CHARACTER NO-UNDO.
END PROCEDURE.
RUN catalogInventoryStockItemUpdate IN hMage_Api_Model_Server_V2_HandlerPortType (INPUT loginReturn, INPUT product, INPUT data, OUTPUT resultado).
DISPLAY resultado.
CATCH mySoapErrorObject AS Progress.Lang.SoapFaultError:
DO iError = 1 TO mySoapErrorObject:NumMessages:
cError = cError + mySoapErrorObject:getMessage(iError) + "~n".
END.
DELETE OBJECT mySoapErrorObject.
END CATCH.
CATCH mySystemErrorObject AS Progress.Lang.SysError:
DO iError = 1 TO mySystemErrorObject:NumMessages:
cError = cError + mySystemErrorObject:getMessage(iError) + "~n".
END.
DELETE OBJECT mySystemErrorObject.
END CATCH.
FINALLY:
IF cError <> "" THEN DO:
MESSAGE "Errors occured:" SKIP
cError
VIEW-AS ALERT-BOX ERROR.
END.
END FINALLY.
END.
hWebService:DISCONNECT().
DELETE OBJECT hWebService.