Passing User Define class to web service.

J

Joel Zinn

I am trying to build a web service that will allow a class instance to be
passed to the web service via a method signature. When I write the client
to consume the web service, I get an error that states, "Value of type
"ExternalNameSpace.myClass" cannot be converted to "localhost/myClass"

Here is how this is set up.
1. I have a class(myClass) defined in a namespace. myClass includes:
a. a class that includes header info in 4 properties (all string values)
b. an array of a second class with one or more detail lines (all string
values)
2. I have a wrapper class the includes a copy of myClass in its definition
3. I have a Public Shared Sub that takes an instance of theWrapper Class as
an input parameter.
4. I create a webmethod on my web service that takes myClass as in input
parameter. The WebMethod:
a. instantiates the wrapper class
b. assigns the myClass parameter to the myClass property of the wrapper
class
c. builds the remaining info to populate the wrapper class
d. calls the method (in item 3 above), passing the wrapper class
5. I built a test harness to test consuming the web service. The test
harness:
a. has a web reference to the Webservice
b. instantiates the myClass object
c. populates the instance with some dummy data
d. instantiates the web service
e. calls the method in the web service, passing the myClass (with the
dummy data)

I get the error message shown at the top, on the signature of the call of
the web service method, where the dummy data myClass is passed

This is the first time I have attempted to create a web service where a
non-primative object is passed to a web method. Can anyone shed any light
on my problem?

Thanks in advance...
 
A

arunprakashb

Hi,
When you are instantiating myClass, try doing it with the namespace
of the web reference added and not from the dll of the myClass, if you
have added this reference to your client also.

Hope this helps.

Regards,
Arun
 
J

Joel Zinn

Thanks for you response. I think I follow you. This is what I did:

In my test harness,
1. I instantiated the ws: theWS as new localhost.myWebService
2. I Attempted to instantiate the ws version of the class: Dim test as new
theWS.myClass

WHen I complete step 2. I get an error message stating "theWS.myClass is not
defined".

Was this what you meant?
 
J

Joel Zinn

I was able to get the instantiation to work by going back one level to
"localhost.myClass". The problem I am getting now is that when the code hits
the Reference.vb code generated by the web reference where the results is
being returned, as below:
Public Function myMethod(ByVal thMssagA As IFWMssagA) As String

Dim results() As Objct = Me.Invoke("myMethod", New Objct() {theMessage})
<-- this line

Return CType(results(0),String)

End Function

I get the error:"Method not found: Void
System.Xml.XmlTextReader.set_ProhibitDtd(Boolean)."
 
B

berto

Joel,

I am replying to step 5. in your description:

Verify that the proxy generated by the web reference does not redefine
myClass. In most cases, using the auto-generated proxy will include
generation of the class definition of the custom class. You will want to
remove the generated class definition and include a reference to the
namespace including the single definition of the class. It seems that the
likely problem is that myClass is multiply defined in separate namespaces and
the proxy is expecting one type and the your test harness is passing in
another type.

berto
 
J

Joel Zinn

berto,
Thanks for the help. That did get me further. The problem I am getting now
is that when the code hits
the Reference.vb code generated by the web reference where the results is
being returned, as below:
Public Function myMethod(ByVal thMssagA As IFWMssagA) As String

Dim results() As Objct = Me.Invoke("myMethod", New Objct() {theMessage})
<-- this line

Return CType(results(0),String)

End Function

I get the error:"Method not found: Void
System.Xml.XmlTextReader.set_ProhibitDtd(Boolean)."

I have searched on this error and can't find very much beyond the suggestion
that I verify that the proxy is current, which it is. Any thoughts on this?
 
B

berto

Joel,

First, you should try to update your web reference, then go to the generated
proxy and verify that the method exists, this is what you most likely found
regarding being up to date. Remember, that when the new web service proxy is
generated it will overwrite any modifications you have made to the current
proxy so make sure you have a backup of your modifications.

Second, if this is unsuccessful, then delete all temporary ASP.net files. I
have encountered errors and know of others encountering errors as a result of
using cached files. Others may be able to explain this in more details since
this approach is primitive, but I and others have found that it works.


Let me know how this goes.

berto
 
J

Joel Zinn

berto, Thanks for your reply.

After updating the proxy and deleting the ASP.net temp files, I still get
the error:
:"Method not found: Void System.Xml.XmlTextReader.set_ProhibitDtd(Boolean)."

I even went back and created a second version of the web service, which
included the classes within the project and namespace, but get the same
error. I am at a loss to figure this out...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top