Getting soap configuration to work

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi all
Really need some help or enlightenment on how to solve this problem have
followed the example on msdn but can't seem to get the SoapExtensiontype to
work in the web.config keep getting a "can't parse or it can't find the file
when I try to run the web service

1 Extension Code copied from MSDN :(traceSoap example)

Imports System
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.IO
Namespace TraceSoapExtension
' Define a SOAP Extension that traces the SOAP request and SOAP response
' for the XML Web service method the SOAP extension is applied to.
Public Class TraceExtension
Inherits SoapExtension

Private oldStream As Stream
Private newStream As Stream
Private m_filename As String

' Save the Stream representing the SOAP request or SOAP response into
' a local memory buffer.
Public Overrides Function ChainStream(ByVal stream As Stream) As
Stream
oldStream = stream
newStream = New MemoryStream()
Return newStream
End Function

' When the SOAP extension is accessed for the first time, the XML Web
' service method it is applied to is accessed to store the file
' name passed in, using the corresponding SoapExtensionAttribute.
Public Overloads Overrides Function GetInitializer(ByVal methodInfo
As _
LogicalMethodInfo, _
ByVal attribute As SoapExtensionAttribute) As Object
Return CType(attribute, TraceExtensionAttribute).Filename
End Function

' The SOAP extension was configured to run using a configuration file
' instead of an attribute applied to a specific XML Web service
' method. Return a file name based on the class implementing the Web
' Service's type.
Public Overloads Overrides Function GetInitializer(ByVal
WebServiceType As _
Type) As Object
' Return a file name to log the trace information to, based on the
' type.
Return "C:\" + WebServiceType.FullName + ".log"
End Function

' Receive the file name stored by GetInitializer and store it in a
' member variable for this specific instance.
Public Overrides Sub Initialize(ByVal initializer As Object)
m_filename = CStr(initializer)
End Sub

' If the SoapMessageStage is such that the SoapRequest or SoapResponse
' is still in the SOAP format to be sent or received over the network,
' save it out to file.
Public Overrides Sub ProcessMessage(ByVal message As SoapMessage)
Select Case message.Stage
Case SoapMessageStage.BeforeSerialize
Case SoapMessageStage.AfterSerialize
WriteOutput(message)
Case SoapMessageStage.BeforeDeserialize
WriteInput(message)
Case SoapMessageStage.AfterDeserialize
End Select
End Sub

' Write the SOAP message out to a file.
Public Sub WriteOutput(ByVal message As SoapMessage)
newStream.Position = 0
Dim fs As New FileStream(m_filename, FileMode.Append, _
FileAccess.Write)
Dim w As New StreamWriter(fs)
w.WriteLine("-----Response at " + DateTime.Now.ToString())
w.Flush()
Copy(newStream, fs)
w.Close()
newStream.Position = 0
Copy(newStream, oldStream)
End Sub

' Write the SOAP message out to a file.
Public Sub WriteInput(ByVal message As SoapMessage)
Copy(oldStream, newStream)
Dim fs As New FileStream(m_filename, FileMode.Append, _
FileAccess.Write)
Dim w As New StreamWriter(fs)

w.WriteLine("----- Request at " + DateTime.Now.ToString())
w.Flush()
newStream.Position = 0
Copy(newStream, fs)
w.Close()
newStream.Position = 0
End Sub

Sub Copy(ByVal fromStream As Stream, ByVal toStream As Stream)
Dim reader As New StreamReader(fromStream)
Dim writer As New StreamWriter(toStream)
writer.WriteLine(reader.ReadToEnd())
writer.Flush()
End Sub


End Class

' Create a SoapExtensionAttribute for our SOAP Extension that can be
' applied to an XML Web service method.
<AttributeUsage(AttributeTargets.Method)> _
Public Class TraceExtensionAttribute
Inherits SoapExtensionAttribute

Private m_filename As String = "c:\log.txt"
Private m_priority As Integer

Public Overrides ReadOnly Property ExtensionType() As Type
Get
Return GetType(TraceExtension)
End Get
End Property

Public Overrides Property Priority() As Integer
Get
Return m_priority
End Get
Set(ByVal Value As Integer)
m_priority = Value
End Set
End Property

Public Property Filename() As String
Get
Return m_filename
End Get
Set(ByVal Value As String)
m_filename = Value
End Set
End Property
End Class
End Namespace

2. My WS Code
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Namespace Users
<WebService(Namespace:="http://tempuri.org/";)> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function

End Class
End Namespace

3. the Web config entry to so that ASP find and can inst.
<webServices>
<soapExtensionTypes>
<add type="TraceSoapExtension.TraceExtension, Users"
priority="1"
group="High"/>
</soapExtensionTypes>
</webServices>

Error I get is
.



Relevant Pages

  • Re: Inserting a SOAP Header in a client request
    ... Every Soap based ... So all you need to do is write to the chained stream using an xml writer. ... custom SoapHeader and modify the ws client proxy by hand to ... > SoapMessage before adding the soap header but that would be ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Exchanging information
    ... The problem with serialised objects is both ends have to be running ... compress the stream, you get a quite compact binary stream. ... You must be able to recreate them after source code changes. ... SOAP helps you waste bandwidth if you have invested in companies like ...
    (comp.lang.java.help)
  • Re: Importing XML through .NET Web Service with VBA
    ... Dim objSClient As MSSOAPLib30.SoapClient30 ' soap object to access and expose web service interface ... ' Call the web service and load requested XML document in to MSXML DOM document structure ... ' save xml document from web service to stream ...
    (microsoft.public.excel.programming)
  • Re: Error on web service: "Server returned internal error 500"
    ... Why dont you use microsoft soap toolkit for intercepting the ... going on when web services correspond with each other (or other ... Stream sendStream = httpReq.GetRequestStream; ...
    (microsoft.public.dotnet.framework.webservices)