Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the data contract serializer used for any third party webservice

I have a large third party webservice; the reference.cs is 33 Mbyte. Using Visual Studio 2017, the proxy uses the XML Serializer, which causes a 5 second delay when creating the channel. I opened a case at Microsoft, and they showed me partially how to modify the reference.cs to use the Datacontract serializer. On the same machine the channel is created in 20 mseconds, which would perfect match my needs.

Unfortunatly the messages fail with small differences, and Microsoft support cannot help.

Are there known restrictions? Any patterns I should look for which makes it for sure it will not work at all and I should start rewriting everything using HTTP Requests?

Actual method which results in overall delay:

public XmlMembersMapping ImportMembersMapping(string elementName, string ns,
  XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors,
  bool validate, XmlMappingAccess access) {
  ElementAccessor element = new ElementAccessor();
  element.IsSoap = true;
  element.Name = elementName == null || elementName.Length == 0 ? elementName : 
    XmlConvert.EncodeLocalName(elementName);
}
like image 615
NickD Avatar asked Jun 19 '17 18:06

NickD


People also ask

What is data contract serializer?

Most important, the DataContractSerializer is used to serialize and deserialize data sent in Windows Communication Foundation (WCF) messages. Apply the DataContractAttribute attribute to classes, and the DataMemberAttribute attribute to class members to specify properties and fields that are serialized.

What is the type of serializer used in WCF?

Windows Communication Foundation (WCF) uses the DataContractSerializer as its default serialization engine to convert data into XML and to convert XML back into data. The DataContractSerializer is designed to serialize data contract types.

What is data contract in Web API?

A data contract is a formal agreement between a service and a client that abstractly describes the data to be exchanged. That is, to communicate, the client and the service do not have to share the same types, only the same data contracts.

What is by serialization with respect to WCF?

The process forms a sequence of bytes into a logical object; this is called an encoding process. At runtime when WCF receives the logical message, it transforms them back into corresponding . Net objects. This process is called serialization.


2 Answers

I've had this problem numerous times. The problem is due to the size of the WSDL that you have from Amadeus. The larger the number of services, the slower it performs. If you create software for air, hotel and car products you end up with a large number of services.

You have two options in this respect;

  1. Ask Amadeus to reduce the size of the WSDL for the services that you need for specific projects. A bit painful.
  2. Edit the WSDL yourself into a smaller size based on your requirements. For example to do hotel search, just create a WSDL package yourself for those few services and then create another WSDL package yourself for the hotel booking part. Performance gain is substantial.

I go with option 2 as getting Amadeus to implement option 1 is painful and not worth the hassle.

like image 124
Dave Avatar answered Oct 18 '22 11:10

Dave


Any patterns I should look for which makes it for sure it will not work at all and I should start rewriting everything using HTTP Requests?

I've made Amadeus integration. Unfortunately, sending HTTP requests was the only solution for me as well. I'm composing Envelopes and "inject" data and send such to webservice and then filling responses by XDocument.

like image 22
Piotr Avatar answered Oct 18 '22 12:10

Piotr