Showing posts with label Web Service. Show all posts
Showing posts with label Web Service. Show all posts

Tuesday, August 23, 2016

Dynamic CRM - Unable to get property 'value' of undefined or null reference.



In this post, I would like to talk about this error while executing a Fetch Xml through Xrm Service Toolkit (JavaScript).

There was an error with this field's customized event.
Field: window
Event: onload
Error: Unable to get property 'value' of undefined or null reference.

The script where the error occured is :

var resultset = XrmServiceToolkit.Soap.Fetch(strFetchXml);

Generally with the research it involved, I found various possibilities that could result in this error message (mainly being missing field in a given form / entity), but that was not the case for me. 

 After spending huge amount of time, it was found that the resultset after executing Fetch XML was null and this error message was part of Xrm Service Toolkit for handling returned data. 

To make it more clear, I added a try / catch for the above statement and added a not null condition for resultset.

if(resultset != null)
{
}

Above implemented action(s) made sure, it didn't throw any error messages and handled properly.

Happy coding....

Wednesday, January 22, 2014

A look into Web API - Creating a simple Web API application... - Part 2



Click here to view part 1



Lets create a model class for our sample and use it to test...





I had created a class called TestData.cs and defined it as below.




As said, I am extending the class from ApiController and added the following code...




Above code will make use of my model TestData to generate some sample data and to display them when invoked.

Now we are all set to run this web service and display the data to end users. When you press F5, you should be able to see the result below.. (I am using chrome to run it)



That's just getting started with Web API's... Happy coding...

A look into Web API - Creating a simple Web API application... - Part 1


ASP.Net Web API is a powerful framework to retrieve data and to serve a broad range of clients. Once created, it can be used to access data within mobile applications too.

   Web API's support developers to create RESTful services and the request is controlled by Controllers, which is similar to MVC controllers, but here the class will be derived from APIController when compared to MVC applications where it will be just Controller. This framework is really helpful to build HTTP based services and can very well control the returned data type  to be json or XML.

   If you are developing an application in MVC, it well suites to have Web API, as it is also based on routing concepts. More over, a given set of data can be accessed/modified through GET,PUT,DELETE etc.....

Now lets see how to create a simple Web API and invoke it through its URL....

I will create a new web API, by making the following choice : ASP.NET MVC 4 Web Application



    After making the selection, make sure you select Web API option (with View Engine type being Razor).



  Sample generated file structure below :


 
   Main controller method inherits from APIController with default value being ValuesController. For tutorial purpose, I will create a new controller WebAPITestController  that would generate and return data on invoking the method.





  Now we have the controller ready. Since this is a regular Controller, we should extend the class with  Sytem.Web.Http.ApiController to make it a Web API or we can select the following option when creating a controller, which will load with few empty basic method structures....






Click here to continue Creating a simple Web API....


 









Sunday, December 27, 2009

Invoke .NET web service from VB6

There are a lot of projects which currently run in VB6 but in an unwilling situation to migrate it to the new version of VB.NET or C#. In one such situation, it was decided to continue using VB6 application with validation done using Web Service created in .NET

I am just including a sample code for writing the same :

VB6 Code :

Dim iFirst As Integer
Dim iSecond As Integer

Dim bNothing As Boolean

Dim MSSCWebSrvc As New MSSOAPLib.SoapClient

Dim objRS As New ADODB.Recordset

On Error Resume Next

'-- Virtual Directory
MSSCWebSrvc.mssoapinit ("http://localhost/test/VBWebService.asmx?wsdl")

If Err.Number = -2147024809 Then
MsgBox "Invalid WebService Request. Please check the URL"
End If

iFirst = 10
iSecond = 5
bNothing = False

'Invoking the AddData method in web service to add the two values.
MsgBox ("Total is : " & MSSCWebSrvc.AddData(iFirst, iSecond))

'To deal with DataSets/Recordsets we can try the following code.

Set objRS = MSSCWebSrvc.objRSReturn()
If objRS.EOF Then
MsgBox " no records "
Else
MsgBox " records found... "
End If

I hope this helps.