0

I'm trying to call a web service hosted in http://gis.hcpid.org/fmoweb/Service.asmx, but I'm getting "Server was unable to process request. ---> Object reference not set to an instance of an object." at run time.

I added the web service in my Visual Studio 2012 using this procedure: right click on project name, Add service reference, Advanced, Add web reference, in URL field I put "http://gis.hcpid.org/fmoweb/Service.asmx", in web reference field I put "GIS" and I click on "Add reference button"

This is my code (C# code):

GIS.Service ResultSvc = new GIS.Service();
string ResultStr = ResultSvc.Find_Address("1234 fake st", "77384");

What I'm doing wrong? Any ideas?

EDIT:------------------------------- Unfortunately, I don't have access to the web service source code. I'm just trying to port a very older webpage (8+ years) to a new asp.net webapp. The older webpage calls the service in this way (VB code)

    Dim gis As GIS2.Service = New GIS2.Service
    Dim xyString As String = Nothing
    Dim txtZipInt As Integer = Nothing
    Dim txtAddress As String = Nothing
    txtZip = "77384"
    txtZipInt = CInt(killChars2(txtZip))
    txtAddress = "1234 fake"
    xyString = gis.Find_Address(txtAddress.ToString, txtZipInt)

In this case, the second parameter is an integer! But the web service expects two string parameters!

John Saunders
  • 157,405
  • 24
  • 229
  • 388
BernieSF
  • 1,318
  • 1
  • 23
  • 40
  • "Server was unable to process request" - Something happened in the service (in this case, something caused a NRE). Do you have access to the service? If not, contact the owner. – Tim Oct 03 '14 at 16:57
  • Unfortunately I don't have access to the service. I'm trying to port a very older website to a new ASP site. One curious thing in the older code, is the fact that the call to the service uses a integer variable for the second parameter (vb code): Dim gis As GIS2.Service = New GIS2.Service Dim xyString As String = Nothing Dim txtZipInt As Integer = Nothing txtZipInt = CInt("77384") xyString = gis.Find_Address("1234 fake", txtZipInt) – BernieSF Oct 03 '14 at 17:03
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Oct 03 '14 at 17:04
  • 2
    Sorry @JohnSaunders I don't see the relation between the "null reference exception" and the "object reference not set to an instance of an object". – BernieSF Oct 03 '14 at 17:12
  • 3
    I would agree that this is not a duplicate, as OP does not have access to the service code. – Tim Oct 03 '14 at 17:14
  • Do you require any special credentials when calling this web Service for example user name and password..? I can consume the same url and I am getting the same error... sounds like you need to contact the vendor / owner of the web service – MethodMan Oct 03 '14 at 17:33
  • @DJKRAZE as far I know, it doesn't require special credentials. My boss just gave me the code for the older webpage, and that code don't contain any credential. The .disco and .wsdl files don't have anything in special :( – BernieSF Oct 03 '14 at 17:39
  • ok here is a test can you run this from the old code..? and if not then that should let you know that there are issues.. – MethodMan Oct 03 '14 at 17:44
  • @DJKRAZE I'm hand tied! The older code was built for .net framework 1.1 !! Even doesn't run on my Win8.1 dev pc. I tried to open the project in the VS 2012 and I just got thousands of errors, and hundred thousands of warnings. Currently is running in production in a *very* older server, *presumably* without errors. I appreciate your interest. – BernieSF Oct 03 '14 at 17:52
  • "Object Reference is not set to an instance of an object" is the message from NullReferenceException. – John Saunders Oct 03 '14 at 18:23
  • @Tim: whether he has access to the code or not, then problem is the same: something is trying to reference an uninitialized object. If he doesn't have access to the code, then he's simply out of luck, as you can't fix broken code without access to the code. – John Saunders Oct 03 '14 at 18:42

0 Answers0