2008-10-22 6 views
2

참고 :.NET SOAP 확장이 MethodInfo에서 NullReferenceException을 던지고 있습니까?

모두 안녕하세요,

내가 로깅 웹 서비스에서 일하고 있어요 IDE로 .NET 2.0을 사용하고 VS2005 저희 데이터베이스 호출, 마지막으로 SoapExtension 구성하고 매우 제거하여 실행되었다 다른 프로젝트에서 이식 된 다운 구현 구성 파일에서 모든 메소드에 대해 실행되도록 설정했습니다. 내 웹 서비스 및 비누 확장 화재를 호출 할 때는, NullPointerException가 SoapServerMessage가 MethodInfo 속성을 호출하려고 할 때 발생합니다 :

LogInput 방법은 processMessage를 (그 SOAPMessage)의 BeforeDeserialize 단계에서라고
System.Web.Services.Protocols.SoapException: There was an exception running the extensions specified in the config file. 
---> System.NullReferenceException: Object reference not set to an instance of an object. 
at System.Web.Services.Protocols.SoapServerProtocol.get_MethodInfo() 
at System.Web.Services.Protocols.SoapServerMessage.get_MethodInfo() 
at MyService.SOAPLoggingExtension.LogInput(SoapMessage message) 
at MyService.SOAPLoggingExtension.ProcessMessage(SoapMessage message) 
at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException) 
at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 
--- End of inner exception stack trace --- 
at System.Web.Services.Protocols.SoapServerProtocol.Initialize() 
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing) 

:

SoapMessageStage.BeforeDeserialize: 
    CopyStream(_oldStream, _newStream); 
    _newStream.Position = 0; 

    if(_enabled) 
     LogInput(message); 
    break; 

LogInput 메서드는 로그하려고하는 메시지 개체의 MethodInfo 속성에 액세스하려고 할 때 실패합니다. 여기서 속성이 호출 코드 블록이다

message.MethodInfo가 호출
entry = new MyServerLogEntry(); 
entry.ServerURL = message.Url; 
entry.Method = (message.MethodInfo == null) ? null : message.MethodInfo.Name; 

그것이 SoapServerProtocol.get_MethodInfo (까지 기포) 및 null 참조 예외가 던져 얻는다. 내가 봤 거든, 여기 주위에 스택 오버플로를 확인하지만, 왜 MethodInfo 속성이 예외를 던질 수 있는지 찾을 수 없습니다.

웹 서비스 호출 중에이 MethodInfo 속성이 제대로 초기화되었는지 확인하는 방법을 아는 사람이 있습니까?

추가 정보 : MethodInfo 속성에 액세스하지 않으면 확장이 제대로 작동하고 내 데이터베이스에 기록됩니다.

답변

2

시행 착오 끝에이 문제를 해결할 수있었습니다. 이유를 완전히 이해하지는 못하더라도 BeforeDeserialize 단계에서 SoapMessage 개체가 완전히 초기화되지 않았습니다. Action 및 MethodInfo 속성은 모두이 단계에서 오류를 발생시킵니다.

그러나 AfterSerialize 단계에서 이러한 개체가 제대로 초기화 된 것 같습니다. 메시지 이름을 읽는 행을 나중 단계로 이동 시키면 로그 항목 오브젝트를 예외없이 throw 할 수 있습니다.

이 올바른 순서가 나타납니다

  1. BeforeDeserialize

    을 수행합니다. 읽기 서버 URL

    b. 요청 정보 검색 (인증서, 사용자 호스트 주소 등)

    c. 스트림

  2. AfterSerialize

    을에서 요청 내용을 읽어보십시오. 읽기 예외

    b. MethodInfo 정보 (필요한 경우 작업 정보)를 읽으십시오.

    c.스트림에서 응답 내용 읽기

1

MSDN에 따르면 메서드 정보는 AfterDeserialization 및 BeforeSerialization 중에 만 사용할 수 있습니다. 그래서 그것은 그 문제의 일부가 될 것입니다.