Reputation: 434
Trying to send a complex type between two systems that have the same code base. They are both aware of the same object that is the data transport medium. However when I pass object on the consumer proxy it appears as an object in the web service namespace instead of the one in the application.
Is there anyway that I can define to use the internal object?
[WebMethod]
public void Run(TransportObject transport)
appears in my application under MyNamespace.Webservice.Transport
instead of MyNamespace.Objects
Upvotes: 0
Views: 1880
Reputation: 273179
[WebMethod]
implies it's an ASMX based service, not a WCF service...
Try again with an [OperationContract]
in a [ServiceContract]
Sharing of Types in WCF is possible, I think it's even the default behaviour.
Upvotes: 1
Reputation: 31750
As Henk says sharing of types in WCF is default behavior.
I will qualify that by expanding on it and demonstrating how to achieve it:
So rather than have visual studio generate a service reference for you, you can have WCF create the proxy when it executes by using ChannelFactory.
For example:
// Create service proxy on the fly
var factory = new ChannelFactory<IMyServiceContract>("NameOfMyClientEndpointInConfigFile");
var proxy = factory.CreateChannel();
// Create data contract
var requestDataContract = new MyRequestType();
// Call service operation.
MyResponseType responseDataContract = proxy.MyServiceOperation(requestDataContract);
In the above example, IMyServiceContract
is your service contract, and MyRequestType
and MyResponseType
are your data contracts, which you can use by referencing the assembly which the service also references (which defines these types).
Upvotes: 1