How to create sales order in Netsuite using SOAP API with TBA credentials? - soap

I have spent more time on creating Sales order in Netsuite using SOAP API with SOAP API. I have tried the following payload and getting error message as Invalid SOAPAction header: get
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:preferences xmlns:ns1="urn:messages_2017_2.platform.webservices.netsuite.com">
<ns1:warningAsError>false</ns1:warningAsError>
<ns1:ignoreReadOnlyFields>true</ns1:ignoreReadOnlyFields>
</ns1:preferences>
<ns2:tokenPassport soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns2="urn:messages_2017_2.platform.webservices.netsuite.com">
<ns3:account xmlns:ns3="urn:core_2017_2.platform.webservices.netsuite.com">{{account}}</ns3:account>
<ns3:consumerKey xmlns:ns3="urn:core_2017_2.platform.webservices.netsuite.com">{{consumerKey}}</ns3:consumerKey>
<ns3:token xmlns:ns3="urn:core_2017_2.platform.webservices.netsuite.com">{{tokenId}}</ns3:token>
<ns3:nonce xmlns:ns3="urn:core_2017_2.platform.webservices.netsuite.com">{{nonce}}</ns3:nonce>
<ns3:signature algorithm="HMAC-SHA256" xmlns:ns3="urn:core_2017_2.platform.webservices.netsuite.com">{{signature}}</ns3:signature>
</ns2:tokenPassport>
</soapenv:Header>
<soapenv:Body>
<add xmlns="urn:messages_2017_2.platform.webservices.netsuite.com">
<record xsi:type="ns4:SalesOrder" xmlns:ns4="urn:sales_2017_2.transactions.webservices.netsuite.com">
<ns4:entity internalId="1655 customer" xsi:type="ns5:RecordRef"
xmlns:ns5="urn:core_2017_2.platform.webservices.netsuite.com">
<ns5:name xsi:type="xsd:string">LAZADA-SG1</ns5:name>
</ns4:entity>
<ns4:tranDate xsi:type="xsd:dateTime">2017-12-14T18:16:44.000Z</ns4:tranDate>
<ns4:shipAddressList internalId="84" xsi:type="ns6:RecordRef"
xmlns:ns6="urn:core_2017_2.platform.webservices.netsuite.com"/>
<ns4:itemList replaceAll="true" xsi:type="ns4:SalesOrderItemList">
<ns4:item xsi:type="ns4:SalesOrderItem">
<ns4:item internalId="387 inventoryItem" xsi:type="ns7:RecordRef"
xmlns:ns7="urn:core_2017_2.platform.webservices.netsuite.com"/>
<ns4:quantity xsi:type="xsd:double">2.0</ns4:quantity>
</ns4:item>
</ns4:itemList>
</record>
</add>
</soapenv:Body>
</soapenv:Envelope>
Also, I have tried different versions.
Can someone help to share the sample SOAP XML payload to create Sales order in netsuite?

It's working
Here I have got the payload to POST the sales order successfully in Netsuite with basic details
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<preferences xmlns="urn:messages_2020_1.platform.webservices.netsuite.com">
<warningAsError>false</warningAsError>
<ignoreReadOnlyFields>true</ignoreReadOnlyFields>
</preferences>
<tokenPassport xsi:type="TokenPassport">
<account>{{account}}</account>
<consumerKey>{{consumerKey}}</consumerKey>
<token>{{tokenId}}</token>
<nonce>{{nonce}}</nonce>
<timestamp>{{timestamp}}</timestamp>
<signature algorithm="HMAC-SHA256">{{signature}}=</signature>
</tokenPassport>
</soap:Header>
<soap:Body>
<add>
<record xsi:type="tranSales:SalesOrder" xmlns:tranSales="urn:sales_2020_1.transactions.webservices.netsuite.com">
<entity internalId="1655"/>
<itemList>
<item>
<item internalId="387"/>
<quantity>3</quantity>
<amount>45.3</amount>
</item>
</itemList>
</record>
</add>
</soap:Body>
</soap:Envelope>

Related

Twinfield every SOAP request failed

Before this project I never worked with SOAP. So I followed all of the instructions from: https://wktaaeu.force.com/nlcommunity/s/article/Setting-up-OAuth-2-0-Introduction?language=en_US and used the Postman templates on that page to make SOAP requests.
After a while I got the Access Token and company code, but I can't find out how to make other requests. With every request that I try to make from different sources on the internet I get the following error:
<?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:Server</faultcode>
<faultstring>Server was unable to process request. ---> Object reference not set to an instance of an object.</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Im making a mistake why every request fails but I can't figure it out.
Examples of different requests I tried
This one I took from: Postman Twinfield API request deleted transactions
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:Authentication xmlns:h="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AccessToken xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">ACCESS_TOKEN</AccessToken>
<CompanyCode xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">35f3248f-46cc-4a8e-b16c-69ac65118771</CompanyCode>
</h:Authentication>
</s:Header>
<s:Body>
<Query i:type="b:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
<b:CompanyCode>COMPANY_CODE</b:CompanyCode>
<b:DateFrom>2022-01-01T00:00:00</b:DateFrom>
<b:DateTo>2022-12-31T23:59:00</b:DateTo>
<b:Daybook></b:Daybook>
</Query>
</s:Body>
</s:Envelope>
Second try was by myself from the docs:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twin="http://www.twinfield.com/">
<soapenv:Header>
<twin:Header>
<twin:AccessToken>ACCESS_TOKEN</twin:AccessToken>
</twin:Header>
</soapenv:Header>
<soapenv:Body>
<twin:ProcessXmlString>
<twin:xmlRequest><![CDATA[<list><type>offices</type></list>]]></twin:xmlRequest>
</twin:ProcessXmlString>
</soapenv:Body>
</soapenv:Envelope>
Last one also made by my reading the docs:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twinfield="http://www.twinfield.com/">
<soap:Header>
<twinfield:Header>
<twinfield:AccessToken>ACCESS_TOKEN</twinfield:AccessToken>
<twinfield:CompanyCode>COMPANY_CODE</twinfield:CompanyCode>
</twinfield:Header>
</soap:Header>
<soap:Body>
<twinfield:ProcessXmlDocument>
<twinfield:xmlRequest>
<read>
<type>dimensions</type>
<office>COMPANY_CODE</office>
<dimtype>SALARIS</dimtype>
<code>1234</code>
</read>
</twinfield:xmlRequest>
</twinfield:ProcessXmlDocument>
</soap:Body>
</soap:Envelope>
I'v had the same struggle as you are going through, after a while I contacted Twinfield about this and they offered me a slightly different soap xml, this is no where explained nor noted down but it worked so maybe it will work for you as well:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:Authentication xmlns:h="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<AccessToken xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">{{Accescode}}</AccessToken>
<CompanyCode xmlns="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.Shared">{{Company}}</CompanyCode>
</h:Authentication>
</s:Header>
<s:Body>
<Query i:type="b:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
<b:CompanyCode>{{Company}}</b:CompanyCode>
<b:DateFrom>2022-06-01T00:00:00</b:DateFrom>
<b:DateTo>2022-07-30T23:59:00</b:DateTo>
<b:Daybook></b:Daybook>
</Query>
</s:Body>
</s:Envelope>
As you can see there a few parameters that you need to set the "Company" and the "Access code"
for the company list I've been using this xml request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twin="http://www.twinfield.com/">
<soapenv:Header>
<twin:Header>
<twin:AccessToken>{{Accescode}}</twin:AccessToken>
</twin:Header>
</soapenv:Header>
<soapenv:Body>
<twin:ProcessXmlString>
<twin:xmlRequest><![CDATA[<list><type>offices</type></list>]]></twin:xmlRequest>
</twin:ProcessXmlString>
</soapenv:Body>
</soapenv:Envelope>
if these dont work it might be that your licence within the twinfield environment needs to be adjusted so you've access to this.

DocuSign SOAP error: This Account lacks sufficient permissions

I am using soap to call CreateEnvelopeFromTemplates. I am embedding the security header at the top and I am getting the response below. Any ideas on what could be wrong.
My security header is:
<soap:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>981ec272-3f9a-4cd8-83a9-062f82fce46c</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">abcdefgh</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
The Response is:
This Account lacks sufficient permissions.
<?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" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<soap:Header>
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/08/addressing/fault</wsa:Action>
<wsa:MessageID>urn:uuid:2a38012a-5ae0-4077-8b81-08a808c62e60</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:6c1f1484-c546-49be-b181-4d75f5dd08a5</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-10879099-ff09-4aa8-bcb8-7f2cf8819781">
<wsu:Created>2019-01-08T16:04:53Z</wsu:Created>
<wsu:Expires>2019-01-08T16:09:53Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>This Account lacks sufficient permissions. </faultstring>
<faultactor>missing in Web.Config</faultactor>
<detail>
<ErrorCode xmlns="missing in Web.Config">111</ErrorCode>
<ErrorReason xmlns="missing in Web.Config">This Account lacks sufficient permissions.</ErrorReason>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
You need to embed your Integrator Key in the Username element, using brackets. Most of the examples shown in the authentication section of the SOAP API guide pre-date Integrator Keys and don't show it for UsernameToken.
Example:
<wsse:Username>[BILL- 9048-469a-a9e9-211cef79e5f3]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>

Element not allowed: node#http://schemas.xmlsoap.org/soap/envelope

I am getting the following error, when I add a SOAP UI schema validation for as part of the assertions in SOAP UI:
Element not allowed: node#http://schemas.xmlsoap.org/soap/envelope in element Header#http://schemas.xmlsoap.org/soap/envelope
Can anyone please give me a clue why this is failing? And how to fix that?
XML validated:
<soap:Envelope xmlns:ns0="urn:xeu:flux-transport:v1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<soap:node datetime="2018-02-02T10:31:08.006Z">ABC</soap:processingNode>
</soap:Header>
<soap:Body>
<blah>
</blah>
</soap:Body>
</soap:Envelope>
WSDL (used to validate in SOAP UI):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>Version: 1.0</wsdl:documentation>
<wsdl:types>
<xsd:schema>
<import namespace="http://schemas.xmlsoap.org/soap/envelope/"
schemaLocation="http://schemas.xmlsoap.org/soap/envelope/" />
</xsd:schema>
</wsdl:types>
</wsdl:definitions>
Any help appreciated.
Remove the element node or below line from your request:
<soap:node datetime="2018-02-02T10:31:08.006Z">ABC</soap:processingNode>
Also, start and end node names are different too.

zend framework Soap

I have to generate following code and presume to do it with zend_soap_client, but I don't know ho to do it, as I have no wsdl file. Here the code:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<processOCIMessage soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<arg0 xsi:type="soapenc:string"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<BroadsoftDocument protocol="OCI"
xmlns="C" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sessionId xmlns="">unique_sessionId </sessionId>
<command xsi:type="ServiceProviderDnGetSummaryListRequest" xmlns="">
<serviceProviderId>your_serviceProvider_Id
</serviceProviderId>
</command>
</BroadsoftDocument>
</arg0>
</processOCIMessage>
</soapenv:Body>
</soapenv:Envelope>
I guess I have to do it in non-wsdl mode...
Any help will be appreciated.
Regards Andrea
If you are requesting a Soap Service,then you will need WSDL URI.
If you are creating a SOAP Service,use the resource
http://bogdan-albei.blogspot.com/2009/05/quickstart-web-services-with-soap-and.html

Auth in sharepoint wsdl

I used soapUI tool for fetch soap request from my dummy wsdl server
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
and take response. But when I try to take request from my real server I cant auth. In soap envelope I added header
<soap:Header>
<AUTHHEADER>
<USERNAME>Administrator</USERNAME>
<PASSWORD>Password</PASSWORD>
</AUTHHEADER>
</soap:Header>
but something wrong. Login and pass is right, I checked.
UPD1
I send query like this
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:AUTHHEADER>
<soap:USERNAME>Administrator</soap:USERNAME>
<soap:PASSWORD>Password</soap:PASSWORD>
</soap:AUTHHEADER>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
and I have
<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>Server was unable to read request. ---> Request format is invalid: Missing required soap:Body element.</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
from real server.
Try to change your query like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:ns0="http://schemas.microsoft.com/sharepoint/soap/">
<ns0:AUTHHEADER>
<ns0:USERNAME>Administrator</ns0:USERNAME>
<ns0:PASSWORD>Password</ns0:PASSWORD>
</ns0:AUTHHEADER>
</soap:Header>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
EDIT1: repair example to add another ns to authheader. Be honest: I don't know, if there is defined an authheader elements in ns of http://schemas.microsoft.com/sharepoint/soap, but I pretend it, because it can be different for every WSDL interface. I know, that there is WSSE standard, but it is coded in XML request differently.