Okay so now I understand (surprised though) - that WebServices can indeed
pass ByRef/ref parameters. All I have to do is mark an integer parameter of
a WebMethod as "ref". Funnily enough, this is also supported per the SOAP
Spec, and from what I understand, .NET's implementation of WebServices,
donot follow the standard, but instead shimmy this behavior by working with
a strict request/response WSDL.
So my question is - If I mark an int as "ref" in a WebMethod, it seems to
work. But if I am exposing a dumb schema (non-intelligent business object),
then it doesn't work. (Dumb Schema Non Intelligent Business object example -
a class customer, with private string FirstName, encapsulated as a
property - that's it !! (Default public constructor present))
Why should this work for only Intrinsic data types? :-/ .. or is there a
trick to making it work with serialized object graphs?
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ 4 2727
> then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
You have now defined a property, not a parameter. The difference is that you cannot define a property as "ref". If, in fact, the
property Type is of a class that inherits from MarshalByRefObject, then it will be marshalled by reference.
--
Dave Sexton dave@www..jwaonline..com
-----------------------------------------------------------------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OC**************@TK2MSFTNGP12.phx.gbl... Okay so now I understand (surprised though) - that WebServices can indeed pass ByRef/ref parameters. All I have to do is mark an integer parameter of a WebMethod as "ref". Funnily enough, this is also supported per the SOAP Spec, and from what I understand, .NET's implementation of WebServices, donot follow the standard, but instead shimmy this behavior by working with a strict request/response WSDL.
So my question is - If I mark an int as "ref" in a WebMethod, it seems to work. But if I am exposing a dumb schema (non-intelligent business object), then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
Why should this work for only Intrinsic data types? :-/ .. or is there a trick to making it work with serialized object graphs?
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
Okay there have been two misunderstandings -
1. I am passing in the customer object as a PARAMETER to a WebMethod. A dumb
schema will have properties - XmlSerialization does not worry about type
info/methods.
2. Okay if I did Customer:MarshalByRefObject - that effectively should not
and will not have any difference. This is XmlSerialization/WebService, not
Remoting. And yes I know WebService is a specialized case of remoting, but
there is a big difference - XmlSerialization vs. Binary/SoapFormatter.
XmlSerialization will try and extract MarshalByRef like any other business
object - no behavior, just soapsuds like dumb metadata - anyway write up a
quick sample to find out what I'm tryin' to say.
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message
news:eE**************@TK2MSFTNGP10.phx.gbl... then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
You have now defined a property, not a parameter. The difference is that you cannot define a property as "ref". If, in fact, the property Type is of a class that inherits from MarshalByRefObject, then it will be marshalled by reference.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OC**************@TK2MSFTNGP12.phx.gbl... Okay so now I understand (surprised though) - that WebServices can indeed pass ByRef/ref parameters. All I have to do is mark an integer parameter of a WebMethod as "ref". Funnily enough, this is also supported per the SOAP Spec, and from what I understand, .NET's implementation of WebServices, donot follow the standard, but instead shimmy this behavior by working with a strict request/response WSDL.
So my question is - If I mark an int as "ref" in a WebMethod, it seems to work. But if I am exposing a dumb schema (non-intelligent business object), then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
Why should this work for only Intrinsic data types? :-/ .. or is there a trick to making it work with serialized object graphs?
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
Yes, there must be some misunderstandings.
I tested it using MarshalByRefObject just to verify that I was correct.
Create a web serivce with a web method and a custom class:
public void MyClass : MarshalByRefObject
{
public string Field = "Initial Value";
}
[WebMethod]
public void ChangeValueByRef(MyClass cls)
{
cls.Field = "New Value";
}
Consume the method:
Service1 service = new Service1();
MyClass cls = new MyClass();
service.ChangeValueByRef(cls);
// outputs "New Value"
Console.WriteLine(cls.Field);
--
Dave Sexton dave@www..jwaonline..com
-----------------------------------------------------------------------
"Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:Od**************@tk2msftngp13.phx.gbl... Okay there have been two misunderstandings -
1. I am passing in the customer object as a PARAMETER to a WebMethod. A dumb schema will have properties - XmlSerialization does not worry about type info/methods. 2. Okay if I did Customer:MarshalByRefObject - that effectively should not and will not have any difference. This is XmlSerialization/WebService, not Remoting. And yes I know WebService is a specialized case of remoting, but there is a big difference - XmlSerialization vs. Binary/SoapFormatter. XmlSerialization will try and extract MarshalByRef like any other business object - no behavior, just soapsuds like dumb metadata - anyway write up a quick sample to find out what I'm tryin' to say.
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:eE**************@TK2MSFTNGP10.phx.gbl... then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
You have now defined a property, not a parameter. The difference is that you cannot define a property as "ref". If, in fact, the property Type is of a class that inherits from MarshalByRefObject, then it will be marshalled by reference.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OC**************@TK2MSFTNGP12.phx.gbl... Okay so now I understand (surprised though) - that WebServices can indeed pass ByRef/ref parameters. All I have to do is mark an integer parameter of a WebMethod as "ref". Funnily enough, this is also supported per the SOAP Spec, and from what I understand, .NET's implementation of WebServices, donot follow the standard, but instead shimmy this behavior by working with a strict request/response WSDL.
So my question is - If I mark an int as "ref" in a WebMethod, it seems to work. But if I am exposing a dumb schema (non-intelligent business object), then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
Why should this work for only Intrinsic data types? :-/ .. or is there a trick to making it work with serialized object graphs?
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
Okay if you put only ByRef - it still works. :-)
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message
news:ec**************@tk2msftngp13.phx.gbl... Yes, there must be some misunderstandings.
I tested it using MarshalByRefObject just to verify that I was correct.
Create a web serivce with a web method and a custom class:
public void MyClass : MarshalByRefObject { public string Field = "Initial Value"; }
[WebMethod] public void ChangeValueByRef(MyClass cls) { cls.Field = "New Value"; }
Consume the method:
Service1 service = new Service1(); MyClass cls = new MyClass(); service.ChangeValueByRef(cls);
// outputs "New Value" Console.WriteLine(cls.Field);
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:Od**************@tk2msftngp13.phx.gbl... Okay there have been two misunderstandings -
1. I am passing in the customer object as a PARAMETER to a WebMethod. A dumb schema will have properties - XmlSerialization does not worry about type info/methods. 2. Okay if I did Customer:MarshalByRefObject - that effectively should not and will not have any difference. This is XmlSerialization/WebService, not Remoting. And yes I know WebService is a specialized case of remoting, but there is a big difference - XmlSerialization vs. Binary/SoapFormatter. XmlSerialization will try and extract MarshalByRef like any other business object - no behavior, just soapsuds like dumb metadata - anyway write up a quick sample to find out what I'm tryin' to say.
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/ "Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:eE**************@TK2MSFTNGP10.phx.gbl... then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
You have now defined a property, not a parameter. The difference is that you cannot define a property as "ref". If, in fact, the property Type is of a class that inherits from MarshalByRefObject, then it will be marshalled by reference.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- "Sahil Malik [MVP]" <co*****************@nospam.com> wrote in message news:OC**************@TK2MSFTNGP12.phx.gbl... Okay so now I understand (surprised though) - that WebServices can indeed pass ByRef/ref parameters. All I have to do is mark an integer parameter of a WebMethod as "ref". Funnily enough, this is also supported per the SOAP Spec, and from what I understand, .NET's implementation of WebServices, donot follow the standard, but instead shimmy this behavior by working with a strict request/response WSDL.
So my question is - If I mark an int as "ref" in a WebMethod, it seems to work. But if I am exposing a dumb schema (non-intelligent business object), then it doesn't work. (Dumb Schema Non Intelligent Business object example - a class customer, with private string FirstName, encapsulated as a property - that's it !! (Default public constructor present))
Why should this work for only Intrinsic data types? :-/ .. or is there a trick to making it work with serialized object graphs?
- Sahil Malik [MVP] http://codebetter.com/blogs/sahil.malik/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Cc |
last post by:
hi,
is there a way to use byref on property set , because i would like to pass
the value into the variable byref ?
|
by: Rob Panosh |
last post by:
Hello,
Ok here is the senerio:
.....
Dim myArrayList as New ArrayList(0)
me.Test_A( myArrayList )
|
by: Carlos Gomez |
last post by:
In VB6 the default for passing variables was ByRef. It was faster and
used less memory. Why did MS changed that? Are there any advantages
using ByVal over ByRef? (other than ByVal impeding you from...
|
by: Robin Tucker |
last post by:
Although I've been working on this project for 8 months now, I'm still not
sure of the difference between ByVal and ByRef. As most objects in VB are
reference types, passing ByVal I've discovered...
|
by: Warren Sirota |
last post by:
Hi,
Please let me know if I am interpreting this correctly. I've done a
little testing of the difference between passing parameters byVal and
byRef, and the results were slightly non-intuitive,...
|
by: barrett bonden |
last post by:
Is there any way to pass parameters to a function and simply know there will
get there without the silly (C like ) complexity of worring about byval and
or perhaps byref ?
(Why bother to...
|
by: Witold Iwaniec via .NET 247 |
last post by:
It seems that when you pass an object to a function it is always passed by reference even if it is explicitly declared ByVal. Is it the behavior of VB.Net?
Here is sample code from sample Asp.Net...
|
by: John Pass |
last post by:
Hi,
In the attached example, I do understand that the references are not changed
if an array is passed by Val. What I do not understand is the result of line
99 (If one can find this by line...
|
by: ari |
last post by:
hey all,
i have the following 2 classes:
Public Class DataAccessLayer
....
....
Public Sub GetRecords(ByRef ds As DataSet1)
ds = New DataSet1
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
| |