【问题标题】:INVALID_TYPE when creating salesforce attachment创建 salesforce 附件时的 INVALID_TYPE
【发布时间】:2014-01-13 16:16:53
【问题描述】:

下面是我从销售人员服务器获得的 XML POST 和响应。 我正在尝试向帐户添加附件,但我不断收到 INVALID_TYPE。

我使用 NuSoap 而不是 SalesForce PHP 库,因为我正在使用的服务器没有所需的 SOAP 扩展。

我对进入和修改库以使其工作没有任何问题,但我不知道 XML 有什么问题来解决问题。我得到查询信息非常好。

感谢所有帮助和建议!

<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
    <nu2113:SessionHeader xmlns:nu2113="urn:enterprise.soap.sforce.com">
        <sessionId>00Di00000{---cutting out for privacy--}UrYmByvpO5yRWIK0Gmy</sessionId>
    </nu2113:SessionHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
    <create xmlns="urn:enterprise.soap.sforce.com">
        <sObject>
            <type xsi:type="xsd:string">Attachment</type>
            <fieldsToNull>
                <elementName xsi:type="xsd:string">fieldsToNull</elementName>
                <values xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[5]">
                    <item xsi:type="xsd:string">OwnerId</item>
                    <item xsi:type="xsd:string">IsPrivate</item>
                    <item xsi:type="xsd:string">IsPartnerShared</item>
                    <item xsi:type="xsd:string">ConnectionSentId</item>
                    <item xsi:type="xsd:string">BodyLength</item>
                </values>
            </fieldsToNull>
            <Id xsi:nil="true"/>
            <ParentId xsi:type="xsd:string">001i000000JG17b</ParentId>
            <Name xsi:type="xsd:string">Test document</Name>
            <Description xsi:type="xsd:string">Test upload from WIN form</Description>
            <ContentType xsi:type="xsd:string">.pdf</ContentType>
            <Body xsi:type="xsd:string">hello</Body>
        </sObject>
    </create>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


HTTP/1.1 100 Continue
HTTP/1.1 500 Server Error
Date: Mon, 13 Jan 2014 15:49:56 GMT
Content-Type: text/xml;charset=UTF-8
Content-Length: 676

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
    <soapenv:Fault>
        <faultcode>sf:INVALID_TYPE</faultcode>
        <faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring>
        <detail>
            <sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
                <sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
                <sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage>
                <sf:row>-1</sf:row>
                <sf:column>-1</sf:column>
            </sf:InvalidSObjectFault>
        </detail>
    </soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

【问题讨论】:

    标签: php soap salesforce nusoap


    【解决方案1】:

    这行可能是问题所在:

    <ContentType xsi:type="xsd:string">.pdf</ContentType>
    

    这不是有效的内容类型。试试这个:

    <ContentType xsi:type="xsd:string">application/pdf</ContentType>
    

    【讨论】:

    • 遗憾的是什么也没做。
    • 同样的错误?你把你上传的pdf文件的base64encoded字符串放入&lt;Body xsi:type="xsd:string"&gt;&lt;/Body&gt;了吗?
    • 是的。我做到了。但我只是用虚拟文本替换了它,因为每次刷新时在 b64 中显示 1MB PDF 是不切实际的。你知道我可以在 XML 中看到一个“创建”请求的示例吗?所有文档都只显示 Java/C# 代码。不是 XML 本身。
    • 我不是肥皂的忠实粉丝,所以我不使用它,因此无法回答。看看他们的 CURL api 使用指南:salesforce.com/us/developer/docs/api_rest/api_rest.pdf‎ - 它似乎有据可查,而且很容易,因为您可以在 php 中使用 curl。
    • 插入 BLOB 的问题并非 100% 由 API 实现。它需要手动启用。 (我宁愿使用它,但被告知没有。)。所以我坚持使用 SOAP 及其可怕之处。
    猜你喜欢
    • 2022-10-20
    • 1970-01-01
    • 1970-01-01
    • 2020-08-18
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多