Microsoft KB Archive/297131

= PRB: &quot;SoapServer.SoapInvoke failed&quot; Error with ASP Listeners =

Article ID: 297131

Article Last Modified on 10/28/2003

-

APPLIES TO


 * Microsoft SOAP Toolkit 2.0
 * Microsoft Active Server Pages 4.0

-



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 = &quot;text/xml&quot; Dim SoapServer If Not Application(&quot;SoapServerInitialized&quot;) Then Application.Lock If Not Application(&quot;SoapServerInitialized&quot;) Then Dim WSDLFilePath Dim WSMLFilePath WSDLFilePath = Server.MapPath(&quot;MyService.wsdl&quot;) WSMLFilePath = Server.MapPath(&quot;MyService.wsml&quot;) Set SoapServer = Server.CreateObject(&quot;MSSOAP.SoapServer&quot;) If Err Then SendFault &quot;Cannot create SoapServer object. &quot; & Err.Description SoapServer.Init WSDLFilePath, WSMLFilePath If Err Then SendFault &quot;SoapServer.Init failed. &quot; & Err.Description Set Application(&quot;MyServiceServer&quot;) = SoapServer Application(&quot;SoapServerInitialized&quot;) = True End If Application.UnLock End If Set SoapServer = Application(&quot;MyServiceServer&quot;) SoapServer.SoapInvoke Request, Response, &quot;&quot; If Err Then SendFault &quot;SoapServer.SoapInvoke failed. &quot; & Err.Description Sub SendFault(ByVal LogMessage) Dim Serializer On Error Resume Next ' &quot;URI Query&quot; logging must be enabled for AppendToLog to work. Response.AppendToLog &quot; SOAP ERROR: &quot; & LogMessage Set Serializer = Server.CreateObject(&quot;MSSOAP.SoapSerializer&quot;) If Err Then Response.AppendToLog &quot;Could not create SoapSerializer object. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; Else Serializer.Init Response If Err Then Response.AppendToLog &quot;SoapSerializer.Init failed. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; Else Serializer.startEnvelope Serializer.startBody Serializer.startFault &quot;Server&quot;, &quot;The request could not be processed due to a problem in the server. Please contact the system admistrator. &quot; & LogMessage Serializer.endFault Serializer.endBody Serializer.endEnvelope If Err Then Response.AppendToLog &quot;SoapSerializer failed. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; 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 = &quot;text/xml&quot; Dim SoapServer If Not Application(&quot;MyService_1_Initialized&quot;) Then Application.Lock If Not Application(&quot;MyService_1_Initialized&quot;) Then Dim WSDLFilePath Dim WSMLFilePath WSDLFilePath = Server.MapPath(&quot;MyService_1.wsdl&quot;) WSMLFilePath = Server.MapPath(&quot;MyService_1.wsml&quot;) Set SoapServer = Server.CreateObject(&quot;MSSOAP.SoapServer&quot;) If Err Then SendFault &quot;Cannot create SoapServer object. &quot; & Err.Description SoapServer.Init WSDLFilePath, WSMLFilePath If Err Then SendFault &quot;SoapServer.Init failed. &quot; & Err.Description Set Application(&quot;MyService_1_Server&quot;) = SoapServer Application(&quot;MyService_1_Initialized&quot;) = True End If Application.UnLock End If Set SoapServer = Application(&quot;MyService_1_Server&quot;) SoapServer.SoapInvoke Request, Response, &quot;&quot; If Err Then SendFault &quot;SoapServer.SoapInvoke failed. &quot; & Err.Description Sub SendFault(ByVal LogMessage) Dim Serializer On Error Resume Next ' &quot;URI Query&quot; logging must be enabled for AppendToLog to work. Response.AppendToLog &quot; SOAP ERROR: &quot; & LogMessage Set Serializer = Server.CreateObject(&quot;MSSOAP.SoapSerializer&quot;) If Err Then Response.AppendToLog &quot;Could not create SoapSerializer object. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; Else Serializer.Init Response If Err Then Response.AppendToLog &quot;SoapSerializer.Init failed. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; Else Serializer.startEnvelope Serializer.startBody Serializer.startFault &quot;Server&quot;, &quot;The request could not be processed due to a problem in the server. Please contact the system admistrator. &quot; & LogMessage Serializer.endFault Serializer.endBody Serializer.endEnvelope If Err Then Response.AppendToLog &quot;SoapSerializer failed. &quot; & Err.Description Response.Status = &quot;500 Internal Server Error&quot; 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.

Additional query words: wsdlgen

Keywords: kbprb KB297131

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.