salesforce SOAP对象到xml代码C#
您好,我正在开发一个WPF应用程序,它使用salesforce合作伙伴WSDL作为web引用,只作为soap引用。我正在获取记录,我正在执行所有操作,如查询、查询、搜索、创建、更新等。我知道记录的格式是sObject,这个sObject有xml记录,而xml记录只是xml元素。 但我需要的是,从上述操作中获得的全部记录,作为xml文件 我的示例代码在这里salesforce SOAP对象到xml代码C#,c#,soap,type-conversion,salesforce,integration,C#,Soap,Type Conversion,Salesforce,Integration,您好,我正在开发一个WPF应用程序,它使用salesforce合作伙伴WSDL作为web引用,只作为soap引用。我正在获取记录,我正在执行所有操作,如查询、查询、搜索、创建、更新等。我知道记录的格式是sObject,这个sObject有xml记录,而xml记录只是xml元素。 但我需要的是,从上述操作中获得的全部记录,作为xml文件 我的示例代码在这里 using System; using System.Collections.Generic; using System.Linq; usin
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Web.Services.Protocols;
using System.Collections;
using System.Xml;
using TestForPartnerWSDL.sforce;
namespace TestForPartnerWSDL
{
public partial class MainWindow : Window
{
SforceService partnerConnection= null;
LoginResult loginResult = null;
public MainWindow()
{
InitializeComponent();
if (Login())
{
#region Select Query
// SOQL query to use
String soqlQuery = "SELECT FirstName, LastName FROM Contact limit 100";
// Make the query call and get the query results
QueryResult qr = partnerConnection.query(soqlQuery);
SObject[] records = qr.getRecords();
}
}
private bool Login()
{
string userName = "MYorgUSERNAME";
string password = "password";
service = new SforceService();
loginResult = new LoginResult();
try
{
loginResult = service.login(userName, password);
}
catch (Exception e)
{
return false;
}
//Change the binding to the new endpoint
service.Url = loginResult.serverUrl; // Set the returned service endpoint URL
//Create a new session header object and set the session id to that returned by the login
service.SessionHeaderValue = new SessionHeader();
service.SessionHeaderValue.sessionId = loginResult.sessionId; // Set the SOAP header with the session ID returned by the login result. This will be included in all API calls.
// Return true to indicate that we are logged in, pointed at the right URL and have our security token in place.
return true;
}
public sealed class temperaryclass
{
//i used this temporary class for getting records using custom constrecter.
}
}
这里我需要从记录对象中提取xml代码。
提前谢谢。这有点难以理解您的问题的措辞。。。我想您要问的是,“我如何才能将
记录
对象中的所有联系人输出为XML文件?”对吗?因为您使用的是Salesforce SDK,所以您有一个实际的模型,而不仅仅是XML。您通常不需要担心XML,只需使用模型提供的方法和字段即可。如果确实需要XML,可以使用XmlSerializer
之类的东西将对象序列化为XML,也可以使用基本HTTP请求而不是web服务引用从SF中提取数据。如果对它们的SOAP端点进行标准HTTP调用,则返回的负载将是XML。