As there could a change in the future to the xml format then I would
need to run the xsd.exe again which is not good.
You are completely correct in that generating a client-side representation of the service contract definition is not good. Far better to reference the actual service definitions in the service assembly, and then construct your channel at run time using ChannelFactory<T>
. This is a far superior approach than using a generated service reference for many reasons.
There are only two things which may stand in your way with this approach:
- You don't have access to the service binaries. Obvioulsy you must be able to consume the actual types used to define the service.
- The service binaries are available, but are compiled into an "uber-assembly" containing all sorts of stuff you don't care about and don't necessarily want to consume from your client app.
If the first of the above two conditions are true then sorry but you must resort to a generated client proxy using xsd.exe and accept all the penalties that this incurrs. If the second condition is true, you may be able to ask the service owner to extract the service definition code into a separate assembly for you and you can proceed as normal using the method described.
i have the class at hand so can use xml serializer...do i just create
a soapEnvelope and then append the generated xml to the body of the
request?
I am assuming the service is also using WCF?
The point of using a framework like WCF is that you don't need to care about the serialization, encoding, and transmission of the data from client to service. WCF takes care of all this for you. All you need to do is create the WCF channel using the service definition (usually this is an interface which defines the service operations as methods on the interface).
Then you can call these methods against the channel instance and the request will be serialized to XML, wrapped in a SOAP wrapper, and transmitted over HTTP to the service, where the request is recieved, unwrapped, and deserialised, again without any effort.
There is an example here: https://stackoverflow.com/a/8869809/569662