While working through the Sample code I need to call the
WhoAmI method of the bizuser class. However I get a 405
Method not allowed error when I try to run it.
I put the code in a Console app that I ran on both the
Client and the server.
Where can this method be run?

Re: BizUser Who am I method returns Error by John

John
Tue May 04 15:39:29 CDT 2004

Send the complete source for a console app where this happens to this
group...just paste it here




"eric" <anonymous@discussions.microsoft.com> wrote in message
news:85af01c43216$7aa15800$a301280a@phx.gbl...
> While working through the Sample code I need to call the
> WhoAmI method of the bizuser class. However I get a 405
> Method not allowed error when I try to run it.
> I put the code in a Console app that I ran on both the
> Client and the server.
> Where can this method be run?



Re: BizUser Who am I method returns Error by Eric

Eric
Tue May 04 15:51:48 CDT 2004

OK here:
using System;
using Microsoft.Crm.Platform.Proxy;
using Microsoft.Crm.Platform.Types;
namespace CRMPOC
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class CrmPOC
{
/// <summary>
/// The main entry point for the
application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start
application here
//

CrmPOC myPOC = new CrmPOC();
myPOC.CreateAccount();
Console.WriteLine("Press Any Key
to Continue");
Console.Read();
}
private void WL(string message)
{
Console.WriteLine(message);
}
private void CreateAccount()
{
string strServer = "London";
string strVirtualDirectory
= "crm/MSCRMServices";
string strDir = "Http://" +
strServer + "/" + strVirtualDirectory + "/";
BizUser oBizUser = new BizUser();
//Ignore commented code clutching
at straws
//System.Net.CredentialCache
oCredentialCache = new System.Net.CredentialCache();
//System.Net.NetworkCredential
oCredential = new System.Net.NetworkCredential
("gailwrsm1","P@ssw0rd","advworks.msft");
//oCredentialCache.Add(new Uri
("http://" + strServer),"NTLM",oCredential);
//oBizUser.Credentials =
oCredentialCache;
oBizUser.Credentials =
System.Net.CredentialCache.DefaultCredentials;
oBizUser.Url = strDir
+ "BizUser.srf";
CRMAccount oAccount = new
CRMAccount();
oAccount.Credentials =
System.Net.CredentialCache.DefaultCredentials;
oAccount.Url = strDir
+ "CRMAccount.srf";
CRMContact oContact = new
CRMContact();
oContact.Credentials =
System.Net.CredentialCache.DefaultCredentials;
oContact.Url = strDir
+ "CRMContact.srf";
string strErrorMessage = "";
try
{
WL("Who");
CUserAuth oUserAuth =
oBizUser.WhoAmI();
WL("Set ACCount xml");
string strAccount
= "<account><name>Account One</name>";
strAccount += "<ownerid
type=\"";
strAccount +=
Microsoft.Crm.Platform.Types.ObjectType.otSystemUser.ToStr
ing();
strAccount += "\">" +
oUserAuth.UserId;
strAccount
+="</ownerid></account>";
WL("Set Contact xml");
string strContact
= "<contact><firstname>Dave</firstname>";
strContact
+= "<lastname>Nashua</lastname>";
strContact
+= "<telephone2>206-555-0100</telephone2>";
strContact
+="<emailaddress1>dave@someaddress.com</emailaddress1>";
strContact += "ownerid
type\"";
strContact +=
Microsoft.Crm.Platform.Types.ObjectType.otSystemUser.ToStr
ing();
strContact += "\">" +
oUserAuth.UserId + "</ownerid></contact>";
WL("Create Account");
string strAccountId =
oAccount.Create(oUserAuth,strAccount);
WL("Create Contact");
string strContactId =
oContact.Create(oUserAuth,strContact);
WL("Add Sub contact");
oAccount.AddSubContact
(oUserAuth,strAccountId, strContactId);
WL("Set Primary Contact");
oAccount.SetPrimaryContact
(oUserAuth,strAccountId,strContactId);
Console.WriteLine
("Account Id: " + strAccountId);
Console.WriteLine
("Contact Id: " + strContactId);

}
catch
(System.Web.Services.Protocols.SoapException err)
{
strErrorMessage = ("Error
Message: " + err.Message + " "
+
err.Detail.OuterXml + " Source: " + err.Source);
Console.WriteLine
(strErrorMessage);
}
catch(Exception err)
{
strErrorMessage = ("Error
Message: " + err.Message + " "
+ "Source: " +
err.Source);
Console.WriteLine
(strErrorMessage);
}
}
}
}

>-----Original Message-----
>Send the complete source for a console app where this
happens to this
>group...just paste it here
>
>
>
>
>"eric" <anonymous@discussions.microsoft.com> wrote in
message
>news:85af01c43216$7aa15800$a301280a@phx.gbl...
>> While working through the Sample code I need to call
the
>> WhoAmI method of the bizuser class. However I get a
405
>> Method not allowed error when I try to run it.
>> I put the code in a Console app that I ran on both the
>> Client and the server.
>> Where can this method be run?
>
>
>.
>