Postman Twinfield API request deleted transactions - soap

I'm trying to request the deleted transactions from the twinfield api. As far as I can get from the documentation I'm making a valid request with Postman but everytime I get a return code 500 -> internal server error.
I'm using the following soap 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:CompanyCode>{{Company}}</twin:CompanyCode>
</twin:Header>
</soapenv:Header>
<s:Body>
<Query i:type="a:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
<b:CompanyCode>{{Company}}</b:CompanyCode>
<b:Daybook>SomeDaybook</b:Daybook>
<b:DateFrom>2021-04-01</b:DateFrom>
<b:DateTo>2021-04-02</b:DateTo>
</Query>
</s:Body>
</s:Envelope>
the headersettings look the following:
headersettings
I've tried it ony the company code as the rest is optional but this gave me the same result.
Any advise on how to get the return with the deleted transactions?

your datefrom and dateto values are invalid. Those should not include the date seperators (-).
this should work:
<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:CompanyCode>{{Company}}</twin:CompanyCode>
</twin:Header>
</soapenv:Header>
<s:Body>
<Query i:type="a:GetDeletedTransactions" xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.DeletedTransactionsService">
<b:CompanyCode>{{Company}}</b:CompanyCode>
<b:Daybook>SomeDaybook</b:Daybook>
<b:DateFrom>20210401000000</b:DateFrom>
<b:DateTo>20210402235959</b:DateTo>
</Query>
</s:Body>
</s:Envelope>

In the end it was de XML schema that was missing, the correct XML envelope needs to look like this
<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-01-01T00:00:00</b:DateFrom>
<b:DateTo>2022-12-31T23:59:00</b:DateTo>
<b:Daybook></b:Daybook>
</Query>
</s:Body>
</s: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.

.Net is messing up SOAP request format

0
I am using .net6 to connect to a SOAP service.
Here is the body that they expect to receive.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.me.com/cpm/xsd/mcpservices/security/v1" xmlns:v11="http://www.me.com/cpm/xsd/mcpservices/cardholdermanagement/v1" xmlns:v12="http://www.me.com/cpm/xsd/mcpservices/base/v1">
<soapenv:Header>
<v1:requestSecurity>
<v1:userName/>
<v1:senderId>Test Desktop</v1:senderId>
<v1:correlationId>000001</v1:correlationId>
<v1:prel>122</v1:prel>
</v1:requestSecurity>
</soapenv:Header>
<soapenv:Body>
<v11:cardAvailablityRequest>
<v12:servicingCentre>90</v12:servicingCentre>
<v12:channel>WEB</v12:channel>
<v11:prel>122</v11:prel>
<v11:lastFourOfCardNumber>2222</v11:lastFourOfCardNumber>
</v11:cardAvailablityRequest>
</soapenv:Body>
</soapenv:Envelope>
However if I look at the request I am sending via the
Request.Content.Message
property
I see this
<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:checkCardAvailability</Action>
<h:requestSecurity xmlns:h="http://www.me.com/cpm/xsd/mcpservices/security/v1" xmlns="http://www.me.com/cpm/xsd/mcpservices/security/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<userName>name</userName>
<senderId>Test Desktop</senderId>
<correlationId>000001</correlationId>
<prel>122</prel>
</h:requestSecurity>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:cardAvailablityRequest>
<servicingCentre>90</v12:servicingCentre>
<channel>WEB</v12:channel>
<prel>122</v11:prel>
<cardNumber>2222</v11:cardNumber>
</h:cardAvailablityRequest>
</s:Body>
</s:Envelope>
What on earth is going on? I used their WSDL to automatically create the proxy classes etc in Visual Studio. I would have thought those classes would form the SOAP correctly?
The WSDL has no instances of the text V11 or V12 so I have no idea how it could possibly know to put those in the Body...
Interestingly if I import the WSDL into SOAPUI it produces the correct Request format (Identical to the top request). Why is .net corrupting the format?

Version mismatch from SOAP API

I am calling SOAP API from postman with following request.
<?xml version="2.0" ?>
<Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<get xmlns:S="http://xml.abc.com/cde/2.xsd" xmlns:S="http://ws.abc.com/cde.2">
<sid>2</sid>
</get>
</Body>
</Envelope>
But, it is giving following response.
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:VersionMismatch</faultcode>
<faultstring>Couldn't create SOAP message. Expecting Envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, but got </faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
Can someone help me, what am I doing wrong.
Your Soap Envelope namespace is incorrect, your request should be something like--
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<ns1:get xmlns:ns1="http://ws.abc.com/cde.2">
<ns1:sid>2</ns1:sid>
</ns1:get>
</soap:Body>
</soap:Envelope>
It is related to the SOAP version. SOAP 1.2 uses http://www.w3.org/2003/05/soap-envelope for the namespace and SOAP 1.1 uses http://schemas.xmlsoap.org/soap/envelope/.
For reference, see http://www.w3.org/TR/soap/ and look at the envelope section in the different version specs.

SOAP fault "DecryptAndDeserializeUserToken" on GetMetaData for Loket

When I post the following to the web service of Loket:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:svc="http://Loket.Webservice/ServiceContracts/2008/06">
<soapenv:Body>
<svc:GetMetaData>
<svc:UserToken>TOKEN_RETRIEVED_WITH_LOGON</svc:UserToken>
</svc:GetMetaData>
</soapenv:Body>
</soapenv:Envelope>
I receive an error:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="nl-NL">GetMetaData</faultstring>
<detail>
<DefaultFaultContract xmlns="http://Loket.Webservice/ServiceContracts/2008/06" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ErrorMessage>DecryptAndDeserializeUserToken</ErrorMessage>
</DefaultFaultContract>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
The error message is misleading. The user token is correct, which you can verify by calling the List method.
However, the as optional listed DataIdentity element is required. It must contain a hashed and encrypted value of the identity of a table, such as:
MqhIh6BdOHPRi1s16c+fNUmm4TO1p7HTwEKxxjgiAjB+o12lO5fq1poK4OZcfOE0yZyvwkDjCcm17foDi7V0uqp06vfgTTv5/y8WyTBz+tPoxVdSOMECHARREMOVEDS4NQz3K8zogL
With this one present, it works. Please note that if you change the DataIdentity value a little, you will still receive a DecryptAndDeserializeUserToken error message.

How to modify soap message parameters

My current SOAP1.1 Message is working well and generating appropriate results. However, SOAP message is taking parameters as arg0, arg1, arg2... I want to pass parameters with tag names like, fName, lName, age,gender.
What changes I do need to make on my server side service to achieve this thing.
<?xml version=1.0 encoding=UTF-8?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<S:Header/>
<S:Body>
<ns2:getRelatedClassModels xmlns:ns2="http://service.accounting.cassit.com/">
<arg0 xsi:type=xsd:string>Aqif</arg0>
<arg1 xsi:type=xsd:string>hameed</arg1>
</ns2:getRelatedClassModels>
</S:Body>
</S:Envelope>
I want it to be like,
<?xml version=1.0 encoding=UTF-8?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<S:Header/>
<S:Body>
<ns2:getRelatedClassModels xmlns:ns2="http://service.accounting.cassit.com/">
<fName>Aqif</fName>
<lName>hameed</lName>
</ns2:getRelatedClassModels>
</S:Body>
</S:Envelope>
<?xml version=1.0 encoding=UTF-8?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<S:Header/>
<S:Body>
<ns2:getRelatedClassModels xmlns:ns2="http://service.accounting.cassit.com/">
<fName>Aqif</fName>
<lName>hameed</lName>
</ns2:getRelatedClassModels>
</S:Body>
</S:Envelope>
This type of message structures are possible with SOAP v1.2 and above. I had to upgrade my SOAP version.