服务器无法处理请求。 - >你调用的对象是空的。 [英] Server was unable to process request. --> Object reference not set to an instance of an object.

查看:268
本文介绍了服务器无法处理请求。 - >你调用的对象是空的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我使用vb.net在Visual Studio 2003中创建了一个Web服务。之后我在IIS 5.1(Win XP SP-2)中托管。网络服务网址为 [ ^ ]。它在我的电脑上工作正常。



这个网络服务将由我的一位为Android应用程序工作的同事消费。

他可以在浏览器中访问此Web服务,但在Android应用程序中访问时出现错误服务器无法处理请求。 - >你调用的对象是空的。



Bellow是代码(vb.net框架1.1)



Dear All,

I have created a web service in Visual Studio 2003 using vb.net. After that I hosted in IIS 5.1 (Win XP SP-2). Url of web service is [^] . It is working fine on my computer.

This web service will be consumed by one of my colleague who is working for android application.
He can access this web service in brow-sure but while access in android application he is getting an error Server was unable to process request. --> Object reference not set to an instance of an object.

Bellow is code(vb.net framework 1.1)

Imports System.Web.Services

Imports System.Reflection
Imports System.Configuration
Imports System.Web.Security
Imports IBM.Data.DB2

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
Public Class CheckHotList
    Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "
 
    Public Sub New()
        MyBase.New()

        'This call is required by the Web Services Designer.
        InitializeComponent()

        'Add your own initialization code after the InitializeComponent() call

    End Sub

    'Required by the Web Services Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Web Services Designer
    'It can be modified using the Web Services Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
    End Sub

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        'CODEGEN: This procedure is required by the Web Services Designer
        'Do not modify it using the code editor.
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

#End Region

#Region "Web Method"
    <WebMethod()> Public Function CheckHotList(ByVal cardSrNo As String) As String
        'Dim result As String = "CIMS Reply from HMS server"
        Dim result As String = "Not Found"
        If Not cardSrNo.Trim = "" Then
            Dim connStr As String = ConfigurationSettings.AppSettings("myConnectionString")
            Dim conn As DB2Connection = New DB2Connection(connStr)
            conn.Open()
            Dim queryString As String = "Select * from CSDINVENTORY_LOG WHERE CARDSRNO_V25=  '" & cardSrNo.Trim & "'"
            Dim cmd As New DB2Command(queryString, conn)
            Dim dr As DB2DataReader = cmd.ExecuteReader()
            If (dr.HasRows) Then
                result = "Found"
            Else
                result = "Not Found"
            End If
            conn.Close()
        End If

        Return result
    End Function

#End Region

End Class





这是我的web.config





Here is my web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    
  <system.web>

    <compilation defaultLanguage="vb" debug="true" />

    <customErrors mode="RemoteOnly" />

    <authentication mode="Windows" /> 

    <authorization>
        <allow users="*" /> <!-- Allow all users -->
    </authorization>

    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />

    <sessionState 
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
	    sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false" 
            timeout="20" 
    />

    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
   
  </system.web>
  
  <appSettings>
	<add key="myConnectionString" value="Server=10.132.210.58:50000;Database=CIMS;UID=cims;PWD=cims;Connect Timeout=30"/>
  </appSettings>

</configuration>





非常感谢任何帮助。



@ Neetin_1809:我使用vs2003而且我认为它不支持JSON。



任何帮助plz ...



Any help is highly appreciated.

@Neetin_1809: I an using vs2003 and I think it is not supporting JSON.

Any help plz ...

推荐答案

在调用cardSrNo.Trim之前检查cardSrNo是否为空
Check that cardSrNo is not null before you call cardSrNo.Trim


这篇关于服务器无法处理请求。 - &GT;你调用的对象是空的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆