How to represent this xml syntax as an object for node soap - node.js

I am trying to consume a soap web service, it works with soap ui but when I use node soap, it does not. I believe the problem is coming from sending a wrong body. This is the body that is to be sent to the web service and this works on soap ui.
<arg0><![CDATA[<C24TRANREQ><PROCESSING_CODE>07</PROCESSING_CODE>
<DR_ACCT_NUM>0711201711</DR_ACCT_NUM><TRAN_CRNCY_CODE>KSD</TRAN_CRNCY_CODE>
</C24TRANREQ> ]]></arg0>
In the object for node-soap, I simply send this below as the args object
const args = {
PROCESSING_CODE: 07,
TRAN_CRNCY_CODE: "KSD",
DR_ACCT_NUM: 0711201711
}
I want to believe my empty response is coming from not including arg0 and C24TRANREQ in my node-soap object. How do I include this?
Also are the numbers to be javascript strings or just numbers?

Related

Why is the Docusign Java SDK is not typesafe?

I'm using the Docusign Java SDK and I'm curious if anyone else noticed it's NOT typesafe. Are there at least constants for the value I can use instead of generic String values.
for example, to send a JSON webhook payload when you use request an envelope signature:
// configure a connect notification
EventNotification eventNotification = new EventNotification();
// Set up the endpoint URL to call (it must be using HTTPS and at least TLS1.1 or higher)
eventNotification.setUrl("my-webhook-url");
// DocuSign will retry on failure if this is set
eventNotification.setRequireAcknowledgment("true"); <---- the String "true"?????
// This would send the documents together with the event to the endpoint
eventNotification.setIncludeDocuments("false"); <---- the String "false"?????
// Allows you to see this in the DocuSign Admin Connect logs section
eventNotification.setLoggingEnabled("true"); <---- the String "true"?????
// send an event when the envelope is sent and completed.
EnvelopeEvent sentEvent = new EnvelopeEvent();
sentEvent.setEnvelopeEventStatusCode("Sent"); <---- the String "Sent"?????
sentEvent.setIncludeDocuments("false");
EnvelopeEvent completedEvent = new EnvelopeEvent();
completedEvent.setEnvelopeEventStatusCode("Completed"); <---- the String "Completed"?????
completedEvent.setIncludeDocuments("false");
eventNotification.setEnvelopeEvents(List.of(sentEvent, completedEvent));
ConnectEventData eventData = new ConnectEventData();
eventData.setVersion("restv2.1"); <---- surely these should be constants....right?
eventData.setFormat("json"); <----
eventNotification.setEventData(eventData);
envelope.setEventNotification(eventNotification);
this documentation led me to use Strings like envelope-completed instead of Completed....which cost me hours of trial and error.
Isn't the whole point of an SDK in a language like Java to be type safe? What am I missing here?
This is not an issue with the Java SDK, but with the swagger file that has definitions for various fields in the DocuSign eSignature REST API.
The swagger file defines many things as strings, even if they do not have to be strings. Changing this now would be a breaking change for many integrations and developers that rely on this (buggy or not) behavior.
This may be fixed in a new version of the API to avoid having backward compatibility issues.

Blue Prism web api service - Cannot send a content-body with this verb-type

I'm having some trouble getting a GET Action with body to work in BluePrism (using web api service).
It seems that when I try to include an Action that sends a GET with body when I reach that stage this error gets thrown:
Internal : Unexpected error Cannot send a content-body with this verb-type.
What I've tried:
Using a different verb-type / passing parameters in the query instead of the body, unfortunately i don't have control over the endpoint i'm trying to reach so this didnt work as it only accepts a GET containing data in the body
Using BluePrism HTTP Utility to send the call, this has the same problem as the Web API Service
Compiling the body via code instead of using a template
I haven't been able to find anyone that made it work in BluePrism and there doesn't seem to be much documentation on this issue in BluePrism so any help would be appreciated.
Thanks!
.NET's WebRequest class that Blue Prism uses under the hood to conduct
these requests will not allow you to send a request body with any GET
request. There is no (documented) way to overcome this limitation.
While other related answers on Stack
Overflow correctly state
that there exists no such prohibition on including request bodies with
GET requests per RFC
9110ยง9.3.1, it is
very unusual for a production-grade service to require that the request
itself include anything in the request body. It's also possible that
intermediaries like HTTP proxies may strip or otherwise mangle the request
body in transit anyway.
There is no out-of-the-box way to force the .NET Framework (which Blue
Prism uses) to send GET requests with a request body. If you're able,
you can install
WinHttpHandler
and implement it as a drop-in replacement for HTTPRequest (this SO
thread will help).
Because this type of solution requires the install of a new library, it's
important to consider the caveats of doing so:
Blue Prism's support for external DLLs is unstable at best, and there's
no guarantee it will even import correctly to begin with. Vendor support
for this type of setup is, anecdotally, limited to nonexistent (and
rightfully so, IMO).
If you're able to successfully implement the functionality described
with WinHttpHandler, you'll need to install it on every Blue Prism
developer's machine and runtime resource in all your environments
(development/SIT/UAT/production). For some organizations, strict IT
security posture makes this rather impractical or outright infeasible.
I managed to get it working using a code block containing C# code and using Reflection, here is a my GET method:
public string GetWithBodyAndAuth(string uri, string data, string token, out int statusCode)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Headers.Add("Authorization", "Basic " + token);
request.ContentType = "application/json; charset=utf-8";
request.Method = "GET";
request.Accept = "application/json";
var type = request.GetType();
var currentMethod = type.GetProperty("CurrentMethod", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(request);
var methodType = currentMethod.GetType();
methodType.GetField("ContentBodyNotAllowed", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentMethod, false);
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(data);
}
var response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
statusCode = ((int)response.StatusCode);
return reader.ReadToEnd();
}
It's a bit of a hack and can't say if it'll be supported in the future, but for BluePrism 6.9 this allows you to send GET requests containing a body.
It has the advantage of not requiring any external DLLs, this is the import list:

How to Use HTTP Receive GET Message in Orchestration?

I have set up a HTTP Receive (req-response) adapter and the message appears to be getting to the message box. When I create an orchestration using a direct bound logical port, I am getting the message but everything I have tried to read the message body has failed (using passthrough pipeline, XML pipeline with allow unrecognized files = true) but I get exceptions any time I try to use the incoming message (message assignments, sending the message to a custom module to try to read the part(s)).
Rather than go into details on exceptions, can anyone point to instructions on what the proper way to access/use the body of the HTTP Get messages within an orchestration? To explain what I am trying to do, I want to take the query string (body) and send it verbatim to another orchestration for processing, so I simply want to extract the body (query string) from the message.
For a GET request without a body you need to use the WCF-WebHttp adapter rather than the deprecated BTSHTTPReceive.dll
With the WCF-WebHttp you can use the Variable Mapping to populate message context properties with the URI parameters.
So the answer was to NOT use the HTTP adapter for GET requests. I did not realize the HTTP adapter has effectively been deprecated. For basic GET requests I had to switch to the WCF-WebHTTP adapter and make sure to include the property in the property schema and then make sure to set the schema in the variable mapping as the property schema, not the message type schema of the incoming message. I wish the Microsoft documentation was more clear that the HTTP adapter cannot be used for very basic GET requests in which a body is not provided in the request.

Sharepoint soap request MTOM

So we have a requirement to upload file to sharepoint server using iOS client . We are able to upload file size till 40kb but the problem is the file data we are passing is in Base64 encoding,and it fails for file size more than 40kb because we cannot pass large data in soap message,so we tried different approaches possible and mentioned on web . These are the ways we tried out
and we are left with only sending data using MTOM .
After lots of experiments and search I think MTOM is a way to upload data using soap . We are using CopyIntoItems sharepoint service for upload .
Soap request looks like
<"xmlns:soap12=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap12:Body>\n"
"<CopyIntoItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
"<SourceUrl>%#</SourceUrl>\n"
"<DestinationUrls>\n"
"<string>%#</string>\n"
"</DestinationUrls>\n"
"<Fields>\n"
"%#"
"</Fields>\n"
"<Stream>MY_FILE_DATA</Stream>\n"
"</CopyIntoItems>\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n"
Now the problem is how do we format this soap request in the way MTOM accepts,because CopyIntoItems may not work in some other format.
Few samples of MTOM which i looked into
http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/cwbs_soapmtom.html
http://cxf.apache.org/docs/mtom.html
Any help would be much appreciated..Thanks..!!
What about using HTTP post and developing an Http handler to store posted data?
It is quite easy to setup an http handler in Sharepoint (MSDN) and in the Process request method you can use query string to get the information you need.
Say you create an Upload.ashx handler.
public void ProcessRequest(HttpContext context)
{
var targetList = context.Request["targetList"];
var targetFileName = context.Request["targetFn"];
// Get the stream to content
var stream = context.Request.GetBufferedInputStream();
// Save the file somewhere
}
From the client you do an HTTP post to http://server/_layouts/15/Upload.ashx?targetList=myFiles&...

Windows Azure - Set Blob Service Properties REST API Call Authentication parameter

I am trying to make a simple REST call to the Set Blob Properties API (http://msdn.microsoft.com/en-us/library/windowsazure/hh452235) to just turn off/on logging. I have gotten the REST API call to successfully work for retrieving Blob Properties, so I know my hashing algorithms, headers-setting, and Authentication signature creation works, but I can't seem to get it working on the Set Properties side of things. I keep getting an error on the Authentication Header, so I know I'm not doing something right there.
I have copied below what is being created and eventually hashed and put into the auth header string. The online documentation (http://msdn.microsoft.com/en-us/library/windowsazure/dd179428) does not really help in determining which of these fields are absolutely required for this particular type of Blob request, so I've tried filling most of them in, but I don't seem to get a difference response regardless of what I fill in. I've also tried the Shared Key Lite authentication, which would be preferred since it's much more lightweight, but that doesn't seem to work either when I fill in all 5 of those fields.
Shared Key Authentication for Blob Services:
PUT\n
\n
\n
130\n
(MD5_CONTENT_HASH)
\n
\n
\n
\n
\n
\n
\n
x-ms-date:Tue, 19 Jun 2012 19:53:58 GMT\n
x-ms-version:2009-09-19\n
/(MY_ACCOUNT)/\n
comp:properties\n
restype:service
Is there anything obvious I'm missing here? The values (MD5_CONTENT_HASH) and (MY_ACCOUNT) are of course filled in when I make the request call, and the similar request call to "GET" the properties works fine when I send it. The only difference between that one and this is that I'm sending the MD5_content, along with the content-length. I may be missing something obvious here, though.
Any advice would be greatly appreciated! Thanks in advance.
-Vincent
EDIT MORE INFO:
Programming Language I'm using: Objective-C (iOS iPhone)
I'm also using ASIHTTPRequest to make the request. I simply define the request, setRequestMethod:#"PUT", then I create the request body and convert it to NSData to calculate the length. I attach the request-body data via the appendPostData method to the request. I then build the auth string above, hash the whole thing, and attach it to the request as a header called "Authorization".
Request Body String I'm using:
<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><Logging><Version>1</Version></Logging></StorageServiceProperties>
I know this is an incomplete request body, but I was planning on waiting for it to give a failure on "missing request body element" or something similar, until I proceeded on creating the full XML there. (could that be my issue?)
Error I get from the server:
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:accc4fac-2701-409c-b1a7-b3a528ce7e8a
Time:2012-06-20T14:36:50.5313236Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request '(MY_HASH)' is not the same as any computed signature. Server used following string to sign: 'POST
130
x-ms-date:Wed, 20 Jun 2012 14:36:50 GMT
x-ms-version:2009-09-19
/(MY_ACCOUNT)/
comp:properties
restype:service'.</AuthenticationErrorDetail></Error>
What's odd is that the error I get back from the server seems to look like that, no matter how many parameters I pass into the Authentication signature.
Thanks for any help you can offer!
Comparing your signed string and the error message indicates that you're sending a POST request but signing as though you're sending a PUT.

Resources