Cecil
19+ years progress programming and still learning.
Using OpenEdge.HTTP.pl
OE 11.7.2
The contents of the response object are giving me the something not quite right, I was expecting XML that has a
content-type "application/xml+soap".
Was expecting:
THe Code:
OE 11.7.2
The contents of the response object are giving me the something not quite right, I was expecting XML that has a
content-type "application/xml+soap".
Code:
OpenEdge.Core.ByteBucket_42683
Was expecting:
Code:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:emp1="urn:www.ird.govt.nz/GWS:types/Employment"
xmlns:emp="https://services.ird.govt.nz/GWS/Employment/"
xmlns:cre="https://services.ird.govt.nz/GWS/Employment/:types/CreateResponse"
xmlns:com="urn:www.ird.govt.nz/GWS:types/Common.v1">
<soap:Header/>
<soap:Body>
<emp:CreateResponse>
<emp:CreateResult>
<cre:CreateResponseWrapper>
<emp1:employmentResponse>
<com:statusCode>0</com:statusCode>
<com:errorMessage></com:errorMessage>
</emp1:employmentResponse>
</cre:CreateResponseWrapper>
</emp:CreateResult>
</emp:CreateResponse>
</soap:Body>
</soap:Envelope>
THe Code:
Code:
/** This conforms the SOAP 1.2 specification **/
ContentTypeHeader = SUBSTITUTE('application/soap+xml; action="&1"; charset=UTF-8':U,
SOAPAction).
AuthorizationHeader = SUBSTITUTE('&1 &2',
Classes.OAuth.OAuthAccessToken:AccessTokenType,
Classes.OAuth.OAuthAccessToken:AccessToken).
DEFINE VARIABLE oRequestBody AS String no-undo.
oRequestBody = NEW STRING(SOAPPayloadXML).
oRequest = RequestBuilder:Post(SOAPEndPointURL, oRequestBody)
:AddHeader('Authorization':U, AuthorizationHeader )
:HttpVersion ("HTTP/1.0")
:ContentType(ContentTypeHeader)
:Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
/** 200 OK Successful **/
IF oResponse:StatusCode EQ 200 AND
oResponse:ContentType EQ "application/soap+xml":U THEN
DO:
DEFINE VARIABLE oEntity AS Progress.Lang.Object NO-UNDO.
DEFINE VARIABLE hXmlDoc AS HANDLE NO-UNDO.
DEFINE VARIABLE oResponseMemptrEntity AS OpenEdge.Core.MEMPTR NO-UNDO.
define variable lcHTML as longchar no-undo.
oEntity = oResponse:Entity.
if type-of(oEntity, JsonObject) then
cast(oEntity, JsonObject):WriteFile('temp/entity.json', true).
ELSE
if type-of(oEntity, WidgetHandle) then
do:
hXmlDoc = cast(oEntity, WidgetHandle):Value.
hXmlDoc:save('file', 'temp/entity.xml').
end.
else
do:
if type-of(oEntity, String) then
lcHTML = cast(oEntity, String):Value.
else
lcHTML = oEntity:ToString().
/* Change extension per the Response's ContentType */
case oResponse:ContentType:
when 'application/json' then
copy-lob lcHTML to file 'temp/entity.json'.
when 'text/html' then
copy-lob lcHTML to file 'temp/entity.html'.
when 'application/xml+soap' then
copy-lob lcHTML to file 'temp/entity2.xml'.
otherwise
copy-lob lcHTML to file 'temp/entity.txt'.
end case.
end.
Last edited: