Problem calling C# web service with Ref parameter from a VB.NET Web application

P

Pratcp

Hello,

I have an asp.net Web app in vb.net trying to call a C# web service
which takes a reference parameter. I tried a simple C# web app to call
the Web service and it works perfectly. However, when I try it in the
vb.net web app, I run into XML definition errors. Looks like the proxy
class is not able to generate the correct XML with the ref parameter.
Here is error:

The element 'urn:test-com:document:test:rfc:functions:T_RETURN has
invalid child element 'urn:test-com:document:test:rfc:functions:item'.
Expected 'urn:test-com:document:test:rfc:functions:ITEM_NUMBER
urn:test-com:document:test:rfc:functions:pO_ITEM_NO

Here is how I am declaring the ref parameter in vb.net

Dim oReturnObj(0) as com.abc.qa.ZRETURNOBJ
oReturnObj(0) = New com.abc.qa.ZRETURNOBJ

Any help will be great.

-PCP
 
J

Joshua Flanagan

I know this doesn't really answer your question, but the advice might
help you more than a direct answer: don't use a ref parameter on a web
service method.

It doesn't make sense. Web services are a cross-process (usually
cross-machine) communication mechanism. The ref keyword is used to allow
the client to change the object reference that a variable points to.
There is no way that your server side code (web service method) will be
able to change the reference to the variable in the client code.

Perhaps you can explain what you were trying to accomplish with the ref
parameter, and we can suggest a better alternative?
Or, if the ref parameter is required by other (non web service) clients
of the method, you might want to make a "wrapper" method without any ref
parameters that is exposed as a web service, and it just calls your
other method internally.

Joshua Flanagan
http://flimflan.com/blog
 
A

agapeton

I second that. This feels weird for something that should really
follow the tennets of service orientation.

Web services should be used in a stateless "service" manner. That is,
it should sit there and take requests and (optionall!) give responses.
You sent it a message, it MAY send a message back. Anything other than
that is kinda weird and violates the Don Box laws. (google 'em)
 
P

Pratcp

Hi Joshua,

Thanks for your response. The Web service itself is being provided by
an external client of ours. We are just making calls from our asp.net
web application to create orders through the external client's Web
service. If I had a choice of creating the Web service, I would agree
that ref parameters is not a good SOA practice. Also, the ref parameter
object does not help us with anything. The Web service fills the order
details with tracking ID etc in the ref parameter object - However, I
can get this from the return object as well!!!!

So, in order to get this working, I had to create a C# class library
within my asp.net solution and add a reference to this library from my
Web application. This resolved the issue with malformed XML for the ref
parameter.

I would still like to know why ref parameters work fine in C# and not
in VB.Net. Is it because:
- I am declaring and using this object in an inconsistent manner or
- is it because C# as a language has greater support compared to vb.net
or
- Should I be tweaking the Proxy class to make sure the parameters get
sent out as ByRef since the default vb.bet implementation is ByVal???

Any further insights will be great!

- PCP
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top