Microsoft Knowledge Base Email Alertz

KBAlertz.com: (297131) - With the Active Server Pages (ASP) files that are generated by WSDL/WSML Generator that ships with Microsoft SOAP Toolkit Version 2, when you try to run multiple SoapServer object instances on the same Web application, you may receive the following...

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 297131 - Last Review: October 28, 2003 - Revision: 2.0

PRB: "SoapServer.SoapInvoke failed" Error with ASP Listeners

This article was previously published under Q297131

SYMPTOMS

With the Active Server Pages (ASP) files that are generated by WSDL/WSML Generator that ships with Microsoft SOAP Toolkit Version 2, when you try to run multiple SoapServer object instances on the same Web application, you may receive the following error message from the SOAP clients:
The request could not be processed due to a problem in the server. Please contact the system admistrator. SoapServer.SoapInvoke failed. Object required.

CAUSE

When you use the WSDL/WSML Generator tool to create ASP pages for ASP Listener projects, the generated ASP code allows only one SoapServer object instance per Web application (virtual folder) to run on a Web server at any point in time.

RESOLUTION

To resolve this problem, use one of the following methods:
  • Modify the ASP pages that are generated by WSDL/WSML Generator, or create new ASP pages based on your requirements.
  • Use the ISAPI Listener instead of the ASP Listener.

STATUS

This behavior is by design.

MORE INFORMATION

The following is an example of a typical ASP page that is created by the WSDL/WSML Generator.
<%@ LANGUAGE=VBScript %>
<%
Option Explicit
On Error Resume Next
Response.ContentType = "text/xml"
Dim SoapServer
If Not Application("SoapServerInitialized") Then
  Application.Lock
  If Not Application("SoapServerInitialized") Then
    Dim WSDLFilePath
    Dim WSMLFilePath
    WSDLFilePath = Server.MapPath("MyService.wsdl")
    WSMLFilePath = Server.MapPath("MyService.wsml")
    Set SoapServer = Server.CreateObject("MSSOAP.SoapServer")
    If Err Then SendFault "Cannot create SoapServer object. " & Err.Description
    SoapServer.Init WSDLFilePath, WSMLFilePath
    If Err Then SendFault "SoapServer.Init failed. " & Err.Description
    Set Application("MyServiceServer") = SoapServer
    Application("SoapServerInitialized") = True
  End If
  Application.UnLock
End If
Set SoapServer = Application("MyServiceServer")
SoapServer.SoapInvoke Request, Response, ""
If Err Then SendFault "SoapServer.SoapInvoke failed. " & Err.Description
Sub SendFault(ByVal LogMessage)
  Dim Serializer
  On Error Resume Next
  ' "URI Query" logging must be enabled for AppendToLog to work.
  Response.AppendToLog " SOAP ERROR: " & LogMessage
  Set Serializer = Server.CreateObject("MSSOAP.SoapSerializer")
  If Err Then
    Response.AppendToLog "Could not create SoapSerializer object. " & Err.Description
    Response.Status = "500 Internal Server Error"
  Else
    Serializer.Init Response
    If Err Then
      Response.AppendToLog "SoapSerializer.Init failed. " & Err.Description
      Response.Status = "500 Internal Server Error"
    Else
      Serializer.startEnvelope
      Serializer.startBody
      Serializer.startFault "Server", "The request could not be processed due to a problem in the server. Please contact the system admistrator. " & LogMessage
      Serializer.endFault
      Serializer.endBody
      Serializer.endEnvelope
      If Err Then
        Response.AppendToLog "SoapSerializer failed. " & Err.Description
        Response.Status = "500 Internal Server Error"
      End If
    End If
  End If
  Response.End
End Sub
%>
				
Note that this code sets the SoapServerInitialized application-level variable during the first run to True after creating the SoapServer object. Because this section of code is common for all the generated ASP pages for all SoapServer objects, subsequent calls to those ASP pages do not initialize the other SoapServer objects, resulting in the failure.

You can modify the generated ASP pages to resolve this problem. For example, you can use multiple application-level initialization variables such as SoapServer1Initialized, SoapServer2Initialized, and so forth to run multiple SoapServer objects on the same Web application. The modified code may resemble the following:
<%@ LANGUAGE=VBScript %>
<%
Option Explicit
On Error Resume Next
Response.ContentType = "text/xml"
Dim SoapServer
If Not Application("MyService_1_Initialized") Then
  Application.Lock
  If Not Application("MyService_1_Initialized") Then
    Dim WSDLFilePath
    Dim WSMLFilePath
    WSDLFilePath = Server.MapPath("MyService_1.wsdl")
    WSMLFilePath = Server.MapPath("MyService_1.wsml")
    Set SoapServer = Server.CreateObject("MSSOAP.SoapServer")
    If Err Then SendFault "Cannot create SoapServer object. " & Err.Description
    SoapServer.Init WSDLFilePath, WSMLFilePath
    If Err Then SendFault "SoapServer.Init failed. " & Err.Description
    Set Application("MyService_1_Server") = SoapServer
    Application("MyService_1_Initialized") = True
  End If
  Application.UnLock
End If
Set SoapServer = Application("MyService_1_Server")
SoapServer.SoapInvoke Request, Response, ""
If Err Then SendFault "SoapServer.SoapInvoke failed. " & Err.Description
Sub SendFault(ByVal LogMessage)
  Dim Serializer
  On Error Resume Next
  ' "URI Query" logging must be enabled for AppendToLog to work.
  Response.AppendToLog " SOAP ERROR: " & LogMessage
  Set Serializer = Server.CreateObject("MSSOAP.SoapSerializer")
  If Err Then
    Response.AppendToLog "Could not create SoapSerializer object. " & Err.Description
    Response.Status = "500 Internal Server Error"
  Else
    Serializer.Init Response
    If Err Then
      Response.AppendToLog "SoapSerializer.Init failed. " & Err.Description
      Response.Status = "500 Internal Server Error"
    Else
      Serializer.startEnvelope
      Serializer.startBody
      Serializer.startFault "Server", "The request could not be processed due to a problem in the server. Please contact the system admistrator. " & LogMessage
      Serializer.endFault
      Serializer.endBody
      Serializer.endEnvelope
      If Err Then
        Response.AppendToLog "SoapSerializer failed. " & Err.Description
        Response.Status = "500 Internal Server Error"
      End If
    End If
  End If
  Response.End
End Sub
%>
				
This design allows the SoapServer objects to be cached on the Web server. You can also create the SoapServer objects and intialization variables at page-level scope instead of caching at application-level scope.

APPLIES TO
  • Microsoft SOAP Toolkit 2.0
  • Microsoft Active Server Pages 4.0
Keywords: 
kbprb KB297131
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please