473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

SOAP Extension error-Value cannot be null

I have created a simple Client-side SOAP Extension for a webclass that I
have. When I apply the extension attribute to the the calling function in the
proxy class I get an error 'Value cannot be null'. When the extension
attribute is not applied it runs fine. The wierd thing is that it does not
appear to be an error within the SOAP extension because I break-pointed it
and when the proxy function gets called the SOAP extension runs fine. After
the end of the subroutine in the SOAP extension it returns back to run the
proxy function and gets an error on the actual call to the webservice. Here
is the function call in the proxy:

'<remarks/>
<SoapDisplayExtension(), _
System.Web.Services.Protocols.SoapDocumentMethodAt tribute( _
"http://tempuri.org/BugTracker2/Service1/GetBug" _
, RequestNamespace:="http://tempuri.org/BugTracker2/Service1" _
, ResponseNamespace:="http://tempuri.org/BugTracker2/Service1" _
, Use:=System.Web.Services.Description.SoapBindingUs e.Literal _
,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped)> _
Public Function GetBug(ByVal BugID As Integer) As Bug
Dim results() As Object
results = Me.Invoke("GetBug", New Object() {BugID})
Return CType(results(0), Bug)
End Function

The error occurs on this line: results = Me.Invoke("GetBug", New
Object() {BugID})

The error is: Unhandled exception of type 'System.ArgumentNullException'
occured in mscorlib.dll. Addition infomation: Value cannot be null

If I remove the attribute: SoapDisplayExtension(), then this line runs fine.

Any ideas?

Thanks!!

PS here is the SOAP extension code and attribute code:

Imports System.IO
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System.Xml.Xsl

Public Class SoapDisplayExtension
Inherits SoapExtension

Private originalStream As Stream
Private internalStream As Stream

Public Overloads Overrides Function GetInitializer(ByVal serviceType As
System.Type) As Object

End Function

Public Overloads Overrides Function GetInitializer(ByVal methodInfo As
System.Web.Services.Protocols.LogicalMethodInfo, ByVal attribute As
System.Web.Services.Protocols.SoapExtensionAttribu te) As Object

End Function

Public Overrides Sub Initialize(ByVal initializer As Object)

End Sub

Public Overrides Function ChainStream(ByVal stream As Stream) As Stream
originalStream = New MemoryStream
ChainStream = internalStream
End Function

Public Overrides Sub ProcessMessage(ByVal message As SoapMessage)
Select Case message.Stage
Case SoapMessageStage.AfterSerialize
internalStream.Position = 0
Dim xslt As XslTransform = New XslTransform
xslt.Load("..\identity.xslt")
Dim xd As XmlDocument = New XmlDocument
xd.Load(internalStream)

Dim ms As MemoryStream = New MemoryStream
xslt.Transform(xd, Nothing, ms, Nothing)

ms.Position = 0
Dim sr As StreamReader = New StreamReader(ms)

Dim f As New DisplayMessage
f.txtMessage.Text = sr.ReadToEnd
f.Show()

internalStream.Position = 0
CopyStream(originalStream, internalStream)
internalStream.Position = 0

Case SoapMessageStage.BeforeDeserialize
CopyStream(originalStream, internalStream)
internalStream.Position = 0

Dim xslt As XslTransform = New XslTransform
xslt.Load("..\identity.xslt")

Dim xd As XmlDocument = New XmlDocument
xd.Load(internalStream)

Dim ms As MemoryStream = New MemoryStream
xslt.Transform(xd, Nothing, ms, Nothing)

ms.Position = 0
Dim sr As StreamReader = New StreamReader(ms)

Dim f As New DisplayMessage
f.txtMessage.Text = sr.ReadToEnd
f.Show()
internalStream.Position = 0

End Select
End Sub

Private Sub CopyStream(ByVal fromStream As Stream, ByVal toStream As
Stream)
Try
Dim sr As New StreamReader(fromStream)
Dim sw As New StreamWriter(toStream)
sw.WriteLine(sr.ReadToEnd)
sw.Flush()
Catch ex As Exception

End Try
End Sub
End Class

Imports System.Web.Services
Imports System.Web.Services.Protocols

<AttributeUsage(AttributeTargets.Method)> _
Public Class SoapDisplayExtensionAttribute
Inherits SoapExtensionAttribute

Private m_Priority As Integer = 1
Public Overrides ReadOnly Property ExtensionType() As System.Type
Get
ExtensionType = GetType(SoapDisplayExtension)
End Get
End Property

Public Overrides Property Priority() As Integer
Get
Priority = m_Priority
End Get
Set(ByVal Value As Integer)
m_Priority = Value
End Set
End Property
End Class
Nov 12 '05 #1
1 5700
Found my problem woo hoo!

I was returning a Null stream from the ChainStream function. I had the code
goofed up in there. Should have been this:

originalStream = Stream
internalStream = new MemoryStream()
ChainStream = internalStream

"David C. allen" wrote:
I have created a simple Client-side SOAP Extension for a webclass that I
have. When I apply the extension attribute to the the calling function in the
proxy class I get an error 'Value cannot be null'. When the extension
attribute is not applied it runs fine. The wierd thing is that it does not
appear to be an error within the SOAP extension because I break-pointed it
and when the proxy function gets called the SOAP extension runs fine. After
the end of the subroutine in the SOAP extension it returns back to run the
proxy function and gets an error on the actual call to the webservice. Here
is the function call in the proxy:

'<remarks/>
<SoapDisplayExtension(), _
System.Web.Services.Protocols.SoapDocumentMethodAt tribute( _
"http://tempuri.org/BugTracker2/Service1/GetBug" _
, RequestNamespace:="http://tempuri.org/BugTracker2/Service1" _
, ResponseNamespace:="http://tempuri.org/BugTracker2/Service1" _
, Use:=System.Web.Services.Description.SoapBindingUs e.Literal _
,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped)> _
Public Function GetBug(ByVal BugID As Integer) As Bug
Dim results() As Object
results = Me.Invoke("GetBug", New Object() {BugID})
Return CType(results(0), Bug)
End Function

The error occurs on this line: results = Me.Invoke("GetBug", New
Object() {BugID})

The error is: Unhandled exception of type 'System.ArgumentNullException'
occured in mscorlib.dll. Addition infomation: Value cannot be null

If I remove the attribute: SoapDisplayExtension(), then this line runs fine.

Any ideas?

Thanks!!

PS here is the SOAP extension code and attribute code:

Imports System.IO
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml
Imports System.Xml.Xsl

Public Class SoapDisplayExtension
Inherits SoapExtension

Private originalStream As Stream
Private internalStream As Stream

Public Overloads Overrides Function GetInitializer(ByVal serviceType As
System.Type) As Object

End Function

Public Overloads Overrides Function GetInitializer(ByVal methodInfo As
System.Web.Services.Protocols.LogicalMethodInfo, ByVal attribute As
System.Web.Services.Protocols.SoapExtensionAttribu te) As Object

End Function

Public Overrides Sub Initialize(ByVal initializer As Object)

End Sub

Public Overrides Function ChainStream(ByVal stream As Stream) As Stream
originalStream = New MemoryStream
ChainStream = internalStream
End Function

Public Overrides Sub ProcessMessage(ByVal message As SoapMessage)
Select Case message.Stage
Case SoapMessageStage.AfterSerialize
internalStream.Position = 0
Dim xslt As XslTransform = New XslTransform
xslt.Load("..\identity.xslt")
Dim xd As XmlDocument = New XmlDocument
xd.Load(internalStream)

Dim ms As MemoryStream = New MemoryStream
xslt.Transform(xd, Nothing, ms, Nothing)

ms.Position = 0
Dim sr As StreamReader = New StreamReader(ms)

Dim f As New DisplayMessage
f.txtMessage.Text = sr.ReadToEnd
f.Show()

internalStream.Position = 0
CopyStream(originalStream, internalStream)
internalStream.Position = 0

Case SoapMessageStage.BeforeDeserialize
CopyStream(originalStream, internalStream)
internalStream.Position = 0

Dim xslt As XslTransform = New XslTransform
xslt.Load("..\identity.xslt")

Dim xd As XmlDocument = New XmlDocument
xd.Load(internalStream)

Dim ms As MemoryStream = New MemoryStream
xslt.Transform(xd, Nothing, ms, Nothing)

ms.Position = 0
Dim sr As StreamReader = New StreamReader(ms)

Dim f As New DisplayMessage
f.txtMessage.Text = sr.ReadToEnd
f.Show()
internalStream.Position = 0

End Select
End Sub

Private Sub CopyStream(ByVal fromStream As Stream, ByVal toStream As
Stream)
Try
Dim sr As New StreamReader(fromStream)
Dim sw As New StreamWriter(toStream)
sw.WriteLine(sr.ReadToEnd)
sw.Flush()
Catch ex As Exception

End Try
End Sub
End Class

Imports System.Web.Services
Imports System.Web.Services.Protocols

<AttributeUsage(AttributeTargets.Method)> _
Public Class SoapDisplayExtensionAttribute
Inherits SoapExtensionAttribute

Private m_Priority As Integer = 1
Public Overrides ReadOnly Property ExtensionType() As System.Type
Get
ExtensionType = GetType(SoapDisplayExtension)
End Get
End Property

Public Overrides Property Priority() As Integer
Get
Priority = m_Priority
End Get
Set(ByVal Value As Integer)
m_Priority = Value
End Set
End Property
End Class

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Doe. | last post by:
Hi PHP gurus! Our team will be creating a web-application that must have an easy to use programmatic interface for our web-developer clients. The data transferred will primarily be taken from a...
0
by: David | last post by:
Hi everyone, I wonder how is it possible to make PHP SOAP extension convert the returned complex type to an instance of one of my classes. Here I give you a short example: complexTest.wsdl:...
4
by: pepcag | last post by:
I used http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp as a template to create a very simple web method with soap...
4
by: Ramon de Klein | last post by:
I have created a SOAP extension that can be enabled using a SoapExtensionAttribute. This attibute holds two additional properties that are used to configure the SOAP extension. This works fine, but...
0
by: zac# | last post by:
i interesting to try using soap extension, and i using sample on msdn. but when i debug my soap extension, i have error message... i invoke soap extension using client desktop application, i want...
0
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. From whast I have read, this should be quite easy to do. Yet I can only activate it from the server. I...
0
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. But so far, I have only been able to activate from the server. I have a service (.asmx file) which...
0
by: maraujo | last post by:
Hi, I have built a customized soap extension in order to log soap messages in client side. Is it possible? On every webservice call, I want to log all soap messages in client side (c:\log.txt...
0
by: israelekpo | last post by:
phpPaypalPro version 0.2.0 Released The second version of phpPaypalPro has been released. phpPaypalPro is an object-oriented framework developed in PHP5 to integrate easily with the Website...
4
by: jatrojoomla | last post by:
I am trying to work with SOAP with php. Even I also add line like $client = new SoapClient('./productSearchService.wsdl', array('trace'=true)); I found error every time like: Fatal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.