Exchange of XML between service and client

Asked

Viewed 264 times

1

I am studying WCF and all the initial material that I find it all comes down to very basic things, exposing methods that receive some parameters and return some value.

I need to create a web service that will be the interface between the database and external applications. External applications can make insertions, deletions and changes to records.

I think this should be done via XML file exchange, that is, for the external application to insert a record of a new client for example, it should send to the Web Service an XML with all the data necessary for the registration of the said client.

How do I implement it?

  • I couldn’t understand your question.

  • But if you are interested in creating webservices that work with you can search for topics like SOAP, WSDL and REST.

  • I only find foolish examples such as a web servisse that exposes a method called soma which takes two integers and returns the result. Thus an application that consumes the service calls the method, passes the two integers and receives the result of the sum. What would be the method responsible for inserting a client, whose registration contains 30 fields? Create a method with 30 parameters one for each field?

  • 1

    Just to clarify. This procedure is done with sending and receiving XML under the table. This simplification, if I’m not mistaken, is called RPC (Remote Procedure call), it seems that you are consuming a local method, but in fact, a call is made to your webservice sending this data and weaving the result via XML.

1 answer

1


The shortest answer is: you don’t implement. The framework does all this for you.

This "simplification", which makes it look like you are calling local methods, is called RPC (remote Procedure call) - which, in my opinion, is one of the most interesting points of WCF and ASMX.

For "under the table" what happens is a sending and receiving of XML’s. However, all this is extremely regulated, with typing, and all the other advantages of making a local call. This "rule" is defined by means of a WSDL file, all webservices developed in WFC, by default you will have this file.

The WSDL also takes care of taking the types (classes) created in the webservice for client application. So, if there is a class Cliente in the webservice, at the moment you create the reference for the same (this is usually done by Visual Studio) this type also happens to exist in the client project.

From there it is only send the object to the remote method that the framework will do all the "dirty work" for you. Obviously you can configure everything, change some things, even choose the data format (JSON, XML, etc.).


WCF is a framework for building service-oriented applications (SOA), you can read some very interesting things in Web Service Type Differences: SOAP, REST, XML.

  • Then the exposed method can receive an object Cliente normally? In this case the external program must also have a client class and pass this object "filled" to the Web Server method. That would be it?

  • The other doubts I’m experiencing with this sequence of videos on WCF by Israel Aece.

  • 1

    @Matheussaraiva That’s right. Note that usually Visual Studio itself will create the classes responsible for the contract in your client project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.