I have thuis webservice. Used to get account information out of microsoft
crm. But is reply's an error! can someone see whats the error in this
code???? Help!
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
using System.Xml;
using Microsoft.Crm.Platform.Proxy;
namespace FetchAllAccounts
{
public class FetchAllAccounts : System.Web.Services.WebService
{
// You must change this to the URL for your Microsoft CRM server.
private const string _strCRMURL = "http://hil-mem-03/mscrmservices/";
/// <summary>
/// Retrieve a summary of all accounts in the database.
/// </summary>
[WebMethod]
public XmlNode Fetch()
{
// Create BizUser proxy object.
BizUser objBizUser = new BizUser();
objBizUser.Credentials
= System.Net.CredentialCache.DefaultCredentials;
objBizUser.Url = _strCRMURL + "BizUser.srf";
// Create CRMQuery proxy object.
CRMQuery objQuery = new CRMQuery();
objQuery.Credentials = objBizUser.Credentials;
objQuery.Url = _strCRMURL + "CRMQuery.srf";
string strAllAccountsFetchXML =
@"<fetch mapping='logical'>
<entity name='account'>
<attribute name = 'name'/>
<attribute name = 'accountid'/>
</entity>
</fetch>";
// Execute the query and return the result set.
// If an exception occurs, return the error message instead.
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.LoadXml(objQuery.ExecuteQuery(objBizUser.Wh oAmI(),
strAllAccountsFetchXML));
return xmlDoc;
}
catch (System.Web.Services.Protocols.SoapException err)
{
xmlDoc.LoadXml("<Error/>");
xmlDoc.DocumentElement.InnerText = strAllAccountsFetchXML; //err.ToString();
return xmlDoc.DocumentElement;
}
}
#region Component Designer generated code
public FetchAllAccounts()
{
//CODEGEN: This call is required by the ASP.NET Web Services Designer
InitializeComponent();
}
//Required by the Web Services Designer
private IContainer components = null;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
}
}