cancel
Showing results for 
Search instead for 
Did you mean: 

Sending XML payload to Ultra pipeline

omair
Contributor

I’m trying to execute an Ultra pipeline with an XML payload, but I’m getting the error below:
Document input views only accept JSON-encoded data
Resolution
Please raise a defect with the following information, Pipeline Ruuid:d3c6dcc2-a498-4517-8df9-54910d504959
Reason
Snap failed unexpectedly and did not provide any reason

ccfa2c2e40288d908578c11adc0deb2afbc9f5ec.png

What steps can be taken to make Ultra parse an XML payload?

10 REPLIES 10

tstack
Former Employee

I think you can, but it’s not as easy as it oughta be right now. These values are available in the header of the binary document that is sent into the pipeline. Unfortunately, the XML Parser doesn’t give you access to the header. Instead, you can use a ‘Binary To Document’ snap to convert the binary document and its header into a regular document. By default, the body of the request is converted into a base64 string and placed in the ‘content’ field. The header data is added directly to the document. As an example, an ultra pipeline with a ‘Binary To Document’ snap and a Mapper that maps ‘$’ to ‘$content’ returns the following when a request is sent:

 curl -k --data-binary '<foo><bar>hi</bar></foo>' -H 'Content-Type: text/xml' 'https://feed1:8082/api/1/rest/feed-master/queue/snaplogic/projects/shared/ts-xml-ultra-task?param1=value1' | jq .
{
  "task_name": "snaplogic/projects/shared/ts-xml-ultra-task",
  "content-length": "24",
  "method": "POST",
  "query": {
    "param1": [
      "value1"
    ]
  },
  "message_id": "8e22c67515a888254fdb859c090c2c6124bfafca-22392@feed1",
  "uri": "https://feed1:8082/api/1/rest/feed-master/queue/snaplogic/projects/shared/ts-xml-ultra-task?param1=value1",
  "content": "PGZvbz48YmFyPmhpPC9iYXI+PC9mb28+",
  "accept": "*/*",
  "client_port": 59455,
  "path_info": "",
  "host": "feed1:8082",
  "server_ip": "10.1.10.222",
  "content-type": "text/xml",
  "client_ip": "10.1.10.222",
  "server_port": 8082,
  "user-agent": "curl/7.45.0"
}

So, you can send the output of the ‘Binary To Document’ into the PipeExec, passing whatever values you want as pipeline parameters. In the child pipeline, it should start with a Document To Binary snap to get back the original XML stream of data and then an XML Parser to parse that.

Sorry, it’s a bit roundabout. The focus has mostly been on requests being JSON-based.

Thanks for the prompt reply! I’ll try this out and let you know if I run into issues.

@dmiller: this would be a great addition to the Ultra pipeline docs!

Thanks,

I’m running into a small issue with my pipelines… My pipelines are now executing correctly (as per the dashboard)…

However, my client is being sent back an HTTP 400 response code:
com.destinyweb.srs.SRSException: HTTP Request failed: HTTP/1.1 400 Bad Request. properties [HTTP/1.1 400 Bad Request, Pipeline did not produce a valid response

My Ultra pipeline looks like this (the response structure is shown):

cb4331d4ae672d49139c17afe53a699b3d77d8b1.png

The response back to the caller is:

[{“one_Awarded_CEUs__c”:“0.11”,“one_Final_Transcript_Grade__c”:“INC”,“one_Transaction_Id__c”:“746895”,“created”:“false”,“status”:200}]

tstack
Former Employee

The “Pipeline did not produce a valid response” message is generated when the document is consumed by a snap and then no actual output document is generated. Take a look at the pipeline execution stats and trace the flow of the documents. You’ll probably see one snap where the document count increases, but the output counts are still zero.

@tstack: now I’m confused… because I’m seeing this occur even on pipelines that have a single path of execution where the document flows through entirely… Here’s a screenshot of an XML request to SnapLogic being made through our system:
bff5a6d6d8fff0f70b1dbc2ba16a10d0dbccc489.png

and here is the log for that execution on the SnapLogic dashboard
Outer pipeline log (makes a Pipeline Execute call)
6e56ac23b2f5307ffa455d0561dc34bbefb1ed36.png

Inner pipeline log
dce7b1aeecbd913f09d2ba4375119fd67de0ca0b.png

The outer pipeline (being triggered) looks like this:
0e196f8b8ced4c1b5bd7cf868531ebe5aea6c0b9.png

The inner pipeline looks like this:
de28412c29928b9c8addf116079780f9b35c882d.png

Is there something else I’m missing?