1. Reyzin Quero
  2. PowerBuilder
  3. Thursday, 30 January 2020 06:00 AM UTC

 PB 12.6 

Here's the part of the code: Thanks.

 

 

String ls_BOUNDARY, ls_mimetype_A = 'application/pdf', ls_mimetype_B = 'text/xml'
Blob blb_multipart

Blob blb_boundary, blb_terminus, blb_filename_A, blb_mimetype_A, blb_file_A
Blob blb_filename_B, blb_mimetype_B, blb_file_B

ls_BOUNDARY = "$$$Boundary$$$"

// build the content
blb_boundary = blob('~r~n--' + ls_Boundary + '~r~n', EncodingUTF8!)
blb_terminus = blob('~r~n--' + ls_Boundary + '--~r~n', EncodingUTF8!)

// Create component blobs - Part: file
blb_filename_A = blob('Content-Disposition: form-data; name="File-Name"' + '~r~n~r~n' + ls_FileName, EncodingUTF8!)
blb_mimetype_A = blob('Content-Disposition: form-data; name="Mime-Type"' + '~r~n~r~n' + ls_MimeType_A, EncodingUTF8!)
blb_file_A = blob( 'Content-Disposition: form-data; name="File"; filename="' + ls_FileName + '"' + '~r~n' + &
"Content-Type: " + ls_MimeType_A + "~r~n~r~n", EncodingUTF8!)

blb_multipart = blb_boundary + &
blb_filename_A + &
blb_mimetype_A + &
blb_file_A


// Create component blobs - Part: form
blb_filename_B = blob('Content-Disposition: form-data; name="Form"' + '~r~n~r~n' + ls_StrXml, EncodingUTF8!)
blb_mimetype_B = blob('Content-Disposition: form-data; name="Mime-Type"' + '~r~n~r~n' + ls_MimeType_B+ "~r~n~r~n", EncodingUTF8!)


blb_multipart += blb_boundary + &
blb_filename_B + &
blb_mimetype_B + &
blb_terminus

 

lobj_dom = CREATE OLEObject
ll_rc_dom = lobj_dom.ConnectToNewObject ("Msxml2.DOMDocument.6.0")

IF ll_rc_dom < 0 THEN
IF IsValid(lobj_dom) THEN DESTROY lobj_dom
ls_error_message = "Unable to connect to the OLE object Msxml2.DOMDocument.6.0.~r~n~r~nError code = '" + String(ll_rc_dom) + "'"
as_error_message = is_dms_message + '~r~rDMS Message: ' + ls_error_message
RETURN -1
END IF


IF gnv_dmssrvc.fnv_connect_endpoint (as_error_message) = 1 THEN
TRY
lobj_xmlhttp.Open("POST", ls_xml_data_param, FALSE)
lobj_xmlhttp.SetRequestHeader("Content-type", "multipart/form-data;boundary="+ ls_BOUNDARY)

lobj_xmlhttp.Send(blb_multipart)

ls_status_text = lobj_xmlhttp.StatusText
ll_status_code = lobj_xmlhttp.Status

ls_response_text = lobj_xmlhttp.ResponseText

Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 31 January 2020 14:04 PM UTC
  2. PowerBuilder
  3. # 1

When debugging web services, it's a good idea to use tools like Fiddler/Wireshark to trap the request/response.  Another super useful tool to get the proper format, and what would probably be super useful for you is SOAPUI.  Try running with that, get the service working and save the working request, then duplicate it from PB.  You can compare it to what you re currently sending and figure out what's wrong.

 

KR

Comment
  1. Reyzin Quero
  2. Monday, 3 February 2020 00:14 AM UTC
Hi Kevin



I did try on SOAPUI and it's working fine. In SOAPUI no coding involved when doing file attachment and I don't if my PB code is correct when sending attachment. Thanks.



  1. Helpful
  1. Kevin Ridley
  2. Tuesday, 4 February 2020 13:27 PM UTC
As I mentioned, capture the working request from SoapUI and duplicate it using the HTTPClient and you'll be all set. The only additional thing will be parsing the result.
  1. Helpful
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 30 January 2020 13:20 PM UTC
  2. PowerBuilder
  3. # 2

Maybe a uppercase / lowercase problem ("Form" vs. "form")?

Comment
  1. Reyzin Quero
  2. Friday, 31 January 2020 00:31 AM UTC
Thanks René Ullrich for the reply unfortunately no luck.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 30 January 2020 08:14 AM UTC
  2. PowerBuilder
  3. # 3

So .... what's the question / problem being a bit more specific?

Comment
  1. Reyzin Quero
  2. Friday, 31 January 2020 00:35 AM UTC
Hi Miguel



First time consuming restful services in PB12.6 and i got the following response: Thanks,





<response>

<status>ERROR</status>

<errorDetails>

<errorType>VALIDATION_ERROR</errorType>

<errorTime>2020-01-30T09:27:13+08:00</errorTime>

<serviceEndpoint>/dev-webservice-3/documents</serviceEndpoint>

<username>wobjective</username>

<messages><message>Missing required part 'form'</message></messages>

</errorDetails>

</response>
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.