사용 중 Visual Studio 및 MS CRM에 액세스하기 위해 원격 서버에 로그인했습니다. 나는 SDK에서 샘플 코드를 촬영하고 코드 실행하려고 한 :MS crm 계정 생성 : System.Net.WebException : 요청이 HTTP 상태 401 : Unauthorized로 실패했습니다.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";
CrmService service = new CrmService();
service.Url= "http://10.16.16.205:5555/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = new System.Net.NetworkCredential"username", "password", "domain");
// Create the account object.
account account = new account();
// Set the properties of the account object.
account.name = "Fourth Coffee123";
account.address1_line1 = "29 Market St.";
account.address1_city = "Sam";
account.address1_stateorprovince = "MT1";
account.address1_postalcode = "9999";
account.donotbulkemail = new CrmBoolean();
account.donotbulkemail.Value = true;
// Create the target object for the request.
TargetCreateAccount target = new TargetCreateAccount();
// Set the properties of the target object.
target.Account = account;
// Create the request object.
CreateRequest create = new CreateRequest();
// Set the properties of the request object.
create.Target = target;
// Execute the request.
CreateResponse created = (CreateResponse)service.Execute(create);
나는 이것에 대한 CRM을 웹 서비스를 사용하고, 그러나 그것의 던지는 예외 :
예외 정보 :
System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
Source Error:
Line 114: [return: System.Xml.Serialization.XmlElementAttribute("Response")]
Line 115: public Response Execute(Request Request) {
210 Line 116: ***object[] results = this.Invoke("Execute", new object[]* {**
Line 117: Request});
는 누락 Line 118: return ((Response)(results[0]));