hello everyone
I'm trying to create a record in crm by web service. I know I have to create a connection string in my web service and it has no problem and when I'm debugging project it answers correctly.
But when I share my program on iis and its going to create record I get this error:
Object reference not set to an instance of an object
I checked them and their ok. You know my code is answering during debug but on iis it cant answer
Hello,
Please check below things for the troubleshoot this issue.
1. So first please check if your are passing the correct parameter to the MSD server to get all the required information for establishment of the connection.
2. This is most important thing please check the firewall settings for the server. Because most of the time your server's firewall will block this responses and because of that connection will not established. and after some time it will show this type of timeout error.
Thank you,
Amit Katariya
Hello Maryam,
Is it hosted anywhere by the iis team. Like is it working on some server or user will run this web service by them selves?
Thank you,
Amit Katariya
look, I checked the code you posted, I don't know if you pasted something different from the code you are running.
this line 13
Entity ownerUser = service.Retrieve("systemuser", Guid.Parse("recordId"), new ColumnSet(true));
doesn't work because Guid.Parse("recordId") gives an exception
oh it seams you you got it wrong I give an ID to Guid.parse() method in format of string
line 13
Entity ownerUser = service.Retrieve("systemuser", Guid.Parse("recordId"), new ColumnSet(true));
you are parsing a string (that contains "recordId") and not a value, that line returns an error
Thanks for your answer
Well my web service is working properly. I have another method and is has no problem in addition I generate a file in my bad method and write in that file during working the method this is my code:
public string GetReceivedFaxes(int receivedFaxId)
{
try
{
1 _logFile = string.Format(@"e:\log\_{0}.txt", Guid.NewGuid());
2 var connectionString = @"AuthType = AD; Url = mycrmAddress/;Username=userName;Password=passWord";
3 Log("test2");
4 CrmServiceClient conn = new CrmServiceClient(connectionString);
5 Log("test3");
6 IOrganizationService service;
7 Log("test4");
8 service = (IOrganizationService)conn.OrganizationWebProxyClient != null ? 9(IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
10 Log("test5");
11 List<receivedFax> allReceivedFax = ReceiveFax(receivedFaxId);
12 Log("test6");
13 Entity ownerUser = service.Retrieve("systemuser", Guid.Parse("recordId"), new ColumnSet(true));
14 EntityReference ownerReference = ownerUser.ToEntityReference();
15 Log(ownerUser.Attributes["fullname"].ToString());
16 for (int i = 0; i < allReceivedFax.Count; i++)
17 {
18 Log("we are ok");
19 Guid recordId = CreateFax(Guid.Parse("recordId"), allReceivedFax[i], ownerReference, service);
20 Log("TEST");
21 Activate(service, recordId, 1, 4);
22 Log(recordId.ToString());
23 Entity recordCreated = service.Retrieve("fax", recordId, new ColumnSet(true));
24 EntityReference recordCreatedReference = recordCreated.ToEntityReference();
25 CreateNoteAttachment("ReceivedFaxMessage", "PDFFileForReceivedFax", allReceivedFax[i].FaxFileBase64, 26recordCreatedReference, service);
27 }
28 return "Fax created by this identifier: " + "\n" + receivedFaxId.ToString();
29 }
30 catch (Exception ex)
31 {
32 return "There is an error: "+ex.Message;
33 }
34
35 }
my problem is in line 13 and 19. I used service.create() method in createfax method and that creates an error.
that error message can refer to different situations, in what you described the most common one is that your webservice is not able to retrieve the connection string when it's deployed to IIS.
First I will make sure if it can be read properly (like just getting the value and put as output of your webservice without connecting it), but without debugging you need to provide some output in a similar way to understand the root problem.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148