我正在嘗試與SalesForce中的SOAP Web服務集成。我的目標是簡單地從SalesForce中提取用戶數據,以便將其集成到我們的系統中。我可以使用從SalesForce網站上的合作伙伴WSDL生成的代理類(C#)成功登錄。我想要做的下一件事是查詢用戶,拉下名字,姓氏等...SalesForce查詢方法不返回可用數據
重要的是要知道,我被迫修改生成的代理服務器代碼,因爲它生成不正確。它填充了xml序列化字段以匹配在進行Web服務調用時引發異常的私有字段。它還爲我刪除的sObject類的「Any」屬性生成了一個空白名稱空間。如果您想了解我爲什麼選擇這些選項,我從this StackOverflow topic獲得了建議。
這是我的查詢看起來是這樣的:
的QRESULT只包含3條記錄(這是準確的,因爲我只有3個用戶)。問題是除了「type」之外,sObject上的每個屬性都始終爲空。
如果我想查詢,或者如果事實,我不得不修改代理類,卸下任何字段的名稱空間是造成這個問題的時候做出一個簡單的錯誤,我想不通。我不知道該怎麼做。開發者控制檯(SalesForce.com)中的相同查詢返回正確的數據。還值得一提的是,我的查詢結果返回了適量的元素,他們只是沒有任何數據。它必須是簡單的東西......比如添加命名空間綁定,但是弄清楚它應該是什麼,或者添加一個xmlbinding到屬性。
我只是想知道如果有人知道該怎麼做。也許有人遇到過同樣的事情?
編輯:所以我花了一些時間來執行一些令人難以置信的hacky技術來攔截來自生成的webservice客戶端的請求,最終我得到了從SalesForce發送的用於響應我的請求的原始數據。那就是:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com">
<soapenv:Body>
<queryResponse>
<result xsi:type="QueryResult">
<done>true</done>
<queryLocator xsi:nil="true"/>
<records xsi:type="sf:sObject">
<sf:type>User</sf:type>
<sf:Id xsi:nil="true"/>
<sf:FirstName>Bob</sf:FirstName>
<sf:LastName>Dyllan</sf:LastName>
<sf:Email>[email protected]</sf:Email>
<sf:CompanyName xsi:nil="true"/>
<sf:Phone xsi:nil="true"/>
<sf:Title xsi:nil="true"/>
</records>
<records xsi:type="sf:sObject">
<sf:type>User</sf:type>
<sf:Id xsi:nil="true"/>
<sf:FirstName>Zachary</sf:FirstName>
<sf:LastName>Sheppard</sf:LastName>
<sf:Email>[email protected]</sf:Email>
<sf:CompanyName>Yahoo</sf:CompanyName>
<sf:Phone xsi:nil="true"/>
<sf:Title xsi:nil="true"/>
</records>
<records xsi:type="sf:sObject">
<sf:type>User</sf:type>
<sf:Id xsi:nil="true"/>
<sf:FirstName xsi:nil="true"/>
<sf:LastName>Chatter Expert</sf:LastName>
<sf:Email>[email protected]</sf:Email>
<sf:CompanyName xsi:nil="true"/>
<sf:Phone xsi:nil="true"/>
<sf:Title xsi:nil="true"/>
</records>
<size>3</size>
</result>
</queryResponse>
</soapenv:Body>
</soapenv:Envelope>
它似乎序列化問題與這些sObjects的「SF」的屬性...但我怎麼做那場比賽了我的C#?這裏是C#,因爲它是目前的的sObject類:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:sobject.partner.soap.sforce.com")]
public partial class sObject
{
/// <remarks/>
public string type;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("fieldsToNull", IsNullable=true)]
public string[]
fieldsToNull;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public string
Id;
/// <remarks/>
public System.Xml.XmlElement[]
Any;
}
你提到的帖子是單聲道的,你用的是單聲道嗎? – superfell
我確實使用單聲道。 –
要清楚,這些不是WSDL的問題,而是單聲道的代理代碼生成器。 – superfell