Netsuite get list of files inside a folder using soap webservice - soap

I am actually trying to get a list of files(or their internalId's) inside a folder using soap webservice from netsuite file cabinet
I am using the following request to make a search request
<soapenv:Header>
<urn:tokenPassport>
<urn1:account xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:account>
<urn1:consumerKey xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:consumerKey>
<urn1:token xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:token>
<urn1:nonce xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:nonce>
<urn1:timestamp xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:timestamp>
<urn1:signature algorithm="HMAC-SHA256" xmlns:urn1="urn:core_2020_2.platform.webservices.netsuite.com">*****</urn1:signature>
</urn:tokenPassport>
</soapenv:Header>
<soapenv:Body>
<search xmlns="urn:messages_2020_2.platform.webservices.netsuite.com">
<searchRecord type="FileSearchBasic" xmlns="urn:common_2020_2.platform.webservices.netsuite.com">
<folder type="SearchMultiSelectField" internalId="2760"/>
</searchRecord>
</search>
</soapenv:Body>
However its giving error following error
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: {urn:core_2020_2.platform.webservices.netsuite.com}SearchRecord is an abstract type and cannot be instantiated</faultstring>

after a lot of research I was able to make a successful soap request to get list of files inside a folder, following is the request body
<soap:Body>
<platformMsgs:search>
<platformMsgs:searchRecord xmlns:s0="urn:filecabinet_2020_2.documents.webservices.netsuite.com" xsi:type="s0:FolderSearchAdvanced">
<s0:criteria>
<s0:basic>
<internalId operator="anyOf">
<searchValue internalId="2760" type="folder" />
</internalId>
</s0:basic>
</s0:criteria>
<s0:columns>
<s0:basic>
<internalId/>
<name/>
</s0:basic>
<fileJoin>
<internalId/>
<name/>
<modified/>
<documentSize/>
</fileJoin>
</s0:columns>
</platformMsgs:searchRecord>
</platformMsgs:search>
</soap:Body>

Related

How to replace soap xml tag value dynamically using cypress

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
<wsse:UsernameToken>
<wsse:Username>abc</wsse:Username>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
In this xml I want to replace the value of wsse:Username to "XYZ" from abc dynamically using cypress ? How to do it ?

How to generate test overview in Frisby

As mentioned in frisby official document (http://frisbyjs.com/) , I am using --junitreport something like following
jasmine-node ./demo/validation_spec.js/ --junitreport --output
C:\Users\Administrator\Documents\script/Reports
which is generating 15 xml files. As I am calling 15 time post using for loop. File contains data like following
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="Frisby Test:blank action " errors="0" tests="1" failures="0" time="0.284" timestamp="2017-03-21T13:55:15">
<testcase classname="Frisby Test: blank action " name="
[ POST https://localhost:8443/api/v2/settings/pointwise ]" time="0.282"></testcase>
</testsuite>
</testsuites>
so my difficulty is that I need to read each and every file to check if tests is pass or not. I want some kind of overview page like http://maven.apache.org/surefire/maven-surefire-report-plugin/surefire-report.html
which contain information how many test passed, fail etc. Is it possible to get that.

Perl - SOAP::Lite request not setting xmlns:soap with correct value on Axis2

I've just created a webservice client in Perl using SOAP::Lite.
I manage to invoke a method of my webservice quite easily, but for some unknown reasons, it works sometimes, and sometimes it won't work.
Here's my perl client code :
my $client = SOAP::Lite->uri("http://loa.webservice")
->service("http://localhost:8888/LogAnalyzerWS/services/DataReceiver?wsdl");
my $res;
do {
sleep(2);
print ("ok \n");
$res = $client->sendData($data);
}while(!defined $res);
print $res, "\n";
I tried to add a while loop to resend the data if the result is undefined, but it won't work.
After some analysis of SOAP::Lite trace log file, I found that during the request, one parameter changes.
Here's the correct xml soap request :
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ax21="http://metier.loa/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://webservice.loa" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns:sendData>
<element xsi:type="xs:base64Binary">PD94bWwgdmVyc2lvbj0</element>
</ns:sendData>
</soap:Body>
</soap:Envelope>
And the correct answer :
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:sendDataResponse xmlns:ns="http://webservice.loa">
<ns:return>1</ns:return>
</ns:sendDataResponse>
</soapenv:Body>
</soapenv:Envelope>
And here's the faulty xml request :
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ax21="http://metier.loa/xsd" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:ns="http://webservice.loa" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<ns:sendData>
<element xsi:type="xs:base64Binary">PD94bWwgdmVyc2lvbj0</element>
</ns:sendData>
</soap:Body>
</soap:Envelope>
With the answer :
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:VersionMismatch</faultcode>
<faultstring>Only SOAP 1.1 or SOAP 1.2 messages are supported in the system</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
As you can see, xmlns:soap hasn't got the same value in the correct and the faulty request : for the correct one, it is :
"http://schemas.xmlsoap.org/soap/envelope/"
And for the faulty one, it is :
"http://schemas.xmlsoap.org/wsdl/soap/"
Any ideas why SOAP::Lite is changing this parameter on it's own ?
The problem comes from the way namespaces are handled in SOAP::Lite.
See this issue on RT cpan. Axis 2 was generating a wsdl which was then parsed by SOAP::Lite, and the value of xmlns:soap from the hash, set by the SOAP::Lite::Serializer, was wrongly being modified by the parsing of the wsdl.
To solve this problem, use this at the very begining of your code (before setting the wsdl in SOAP::Lite) :
$SOAP::Constants::PREFIX_ENV = 'SOAP-ENV';
Also one can use method envprefix:
$client->envprefix('SOAP-ENV');
This code works for me:
use SOAP::Lite +trace => [ qw(debug) ]; # to get all logging without transport messages
my $service = SOAP::Lite->service('https://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL');
$service->soapversion('1.1');
$service->readable(1);
$service->envprefix('SOAP-ENV');
$service->bodyattr({ xmlns => 'http://web.cbr.ru/' });
my $result = $service->GetCursOnDate('2021-02-05T00:00:00');

using curl to interact with REST API - error: "Content not allowed in prolog"

I am sending the following curl command from terminal in Mac OSX:
curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=1AD….4&INPUT_DATA=TestData.xml" http://xxx.xx.xx.xx/sdpapi/request/
I am getting back the response:
FailedError when performing - ADD_REQUEST - Content is not allowed in prolog.
Here is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Operation>
<Details>
<requester>Me</requester>
<subject>Test</subject>
<description>Testing curl input</description>
</Details>
</Operation>
I have checked and my xml file is indeed a UTF-8 file. I can tell from google searches that this most likely has to do with my encoding, however, I can't find how to fix it.
I've also tried saving the xml file as ANSI on my pc, xml file looks like this:
<?xml version="1.0"?>
<Operation>
<Details>
<requester>Me</requester>
<subject>Test</subject>
<description>Testing curl input</description>
</Details>
</Operation>
I downloaded Notepad++ and checked the encoding, which is UTF8 with no BOM.
I am still getting the same error. Can anyone see what I am doing wrong?
Updated 9/19 to add:
In addition to everything I've tried in the comments below, I've also tried this:
curl -d "OPERATION_NAME=ADD_REQUEST&TECHNICIAN_KEY=xxxxxxxxxxxxxxxxx&INPUT_DATA=<?xml version="1.0" encoding="utf-8"?><Operation><Details><requester>Me</requester><subject>Test</subject><description>Testing curl input</description></Details></Operation>" http://xxx.xx.xx.xx/sdpapi/request/
The error I'm getting now is: "Error when performing - ADD_REQUEST - The value following "version" in the XML declaration must be a quoted string."
Anyone have any thoughts?
I replaced <?xml version="1.0" encoding="utf-8"?> with <?xml version=%221.0%22 encoding=%22utf-8%22?>
It is now working.

Consuming .Net Web Service using Perl and SOAP Lite

I'm trying to consume a .Net Web Service using perl and SOAP Lite.
When I consume the web service in a .Net client - it posts to the .asmx endpoint the following:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://mysoapnamespace.com/"
xmlns:types="http://mysoapnamespace.com/encodedTypes">
<soap:Body>
<tns:HellowWorld />
</soap:Body>
</soap:Envelope>
How can I generate that same request using SOAP Lite? I've been through a variety of SOAP Lite docs and articles with no luck. So far I have the following:
#!/usr/bin/perl
use SOAP::Lite 'trace', 'debug' ;
$api_ns = "https://mysoapnamespace.com";
$api_url = "http://mysoapnamespace/api.asmx";
$action = "HelloWorld";
my $soap = SOAP::Lite
-> readable(1)
-> uri($api_ns)
-> proxy($api_url)
-> on_action(sub { return "\"$action\"" }) ;
return $soap->HellowWorld();
This generates this, incorrect XML:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HellowWorld xmlns="http://mysoapnamespace.com" xsi:nil="true" />
</soap:Body>
</soap:Envelope>
Update:
When I post the 1st xml to my service using fiddler it returns my "Hello World" result. When I post the 2nd I get the following:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (9, 6). ---> System.InvalidOperationException: <HellowWorld xmlns='http://mysoapnamespace.com'> was not expected.
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read21_HellowWorld()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer28.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
Found the problem - the trailing slash on the namespace. .Net just figures that stuff out for your but it needs to be explicitly set in Perl. Also, figured out how to us the ns() function to add names spaces.
This will generate the correct XML.
#!/usr/bin/perl
use SOAP::Lite 'trace', 'debug' ;
$api_ns = "https://mysoapnamespace.com/";
$api_url = "http://mysoapnamespace/api.asmx";
$action = "HelloWorld";
my $soap = SOAP::Lite
-> readable(1)
-> ns($api_types,'types')
-> ns($api_ns,'tns')
-> proxy($api_url)
-> on_action(sub { return "\"$action\"" }) ;
return $soap->HellowWorld();
This link was very helpful in figuring out SOAP::Lite - http://kobesearch.cpan.org/htdocs/SOAP-Lite/SOAP/Lite.pm.html
I had to do the following to get it to work (add this line after my $soap... line):
$soap->ns('http://schemas.xmlsoap.org/soap/envelope/',"s");
I hope this will save someone some time... It took a while to get it figured out... :-)
BTW: I am using .Net 4.5 WCF with a windows service for Web Service server and Perl (activestate) V5.16.3 with SOAP::Lite V 1.08.