首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Twinfield每个SOAP请求失败

Twinfield每个SOAP请求失败
EN

Stack Overflow用户
提问于 2022-08-02 13:01:39
回答 1查看 91关注 0票数 1

在这个项目之前,我从未使用过SOAP。因此,我遵循了来自:https://wktaaeu.force.com/nlcommunity/s/article/Setting-up-OAuth-2-0-Introduction?language=en_US的所有说明,并使用该页面上的Postman模板来发出SOAP请求。

过了一段时间,我得到了访问令牌和公司代码,但我无法找到如何发出其他请求。对于我试图从互联网上的不同来源发出的每一个请求,我都会得到以下错误:

代码语言:javascript
复制
<?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. ---&gt; Object reference not set to an instance of an object.</faultstring>
            <detail />
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

我犯了一个错误,为什么每个请求都失败了,但我搞不清楚。

我尝试过的不同请求的例子

这是我从Postman Twinfield API request deleted transactions上拿来的

代码语言:javascript
复制
<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>

第二次尝试是由医生自己做的:

代码语言:javascript
复制
<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>

最后一篇也是我读文档时做的:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2022-08-04 09:52:20

我和你经历过同样的挣扎,过了一段时间,我联系了Twinfield,他们给我提供了一个稍微不同的soap,这是没有解释的,也没有记录下来,但是效果很好,所以也许它也适用于您:

代码语言:javascript
复制
<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>

如您所见,设置"Company“和"Access代码”需要一些参数

对于公司列表,我一直在使用以下xml请求:

代码语言:javascript
复制
<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>

如果这些不起作用,可能是你的许可证在双工场环境中需要调整,这样你就可以获得这个。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73208033

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档