none
BizTalk schema and Service call RRS feed

  • Question

  • Hi

    I am calling Service from BizTalk Orchestration and  I have another scenario i need to call same service from .Net code.

    Do i need to again add service reference in .net Code or can i use  BizTalk project(Which has service schema)?


    Saturday, August 27, 2016 2:21 AM

Answers

All replies

  • Hi do you mean your service is calling another .net class behind the scene? If yes you don't need to reference this another .net class. Your BizTalk project , a single reference to the service proxy is all you need.

    Regards Pushpendra Singh : Please mark the reply as answer or vote it up, as deemed fit.

    Saturday, August 27, 2016 4:37 AM
  • Hi

    Calling web services from .NET is best done through a proxy class that is generated by Visual Studio tooling. The artifacts generated when you consume a web service in BizTalk project won't work well with pure .NET code.

    You have "Add Service Reference" option in non-BizTalk projects that creates the proxy classes for web/WCF services that you can use to make the call to the service. You can also use the "svcutil" tool to generate the proxy for you. If you have the .wsdl file for the service, you can provide the path to the .wsdl file when you run "Add Service Reference".

    AddServiRef.png

    You can refer below links-

    http://www.c-sharpcorner.com/UploadFile/0c1bb2/consuming-wcf-service-in-windows-application/

    http://www.csharptutorial.in/34/csharp-net-how-to-consume-a-wcf-web-service-in-visual-studio-2010

    For .asmx service-

    http://www.aspsnippets.com/Articles/Call-Consume-Web-Service-ASMX-in-Console-application-using-C-and-VBNet.aspx


    Thanks Arindam



    Saturday, August 27, 2016 4:46 AM
    Moderator
  • Pretty quick in marking the answer. 

    Please read and follow these guidelines: http://social.technet.microsoft.com/wiki/contents/articles/1059.forum-moderation-guide-managing-posts-and-threads-marking-answers.aspx#Guidance

    Especially look at the guidelines about proposing answers and then marking them 7 days later.

    Ammu,

    Most importantly, from a service orientation perspective you should keep BizTalk and .NET artifacts in different projects and you should also abstract the service artifacts from the other artifacts. Otherwise it will be very difficult to update the service interface without affecting the other artifacts. For example you don't want to have to redeply your entire application if only one field changes in the service you consume.

    Best Practice:

    It is bad practice to use Add Service Reference to consume web service in BizTalk Project.

    When you use the Add Service Reference to add service references to BizTalk projects, BizTalk Server converts the schema types that are required to call each Web method to schemas. BizTalk Server adds these schemas to Reference.xsd. If your schemas contain element names that are C# keywords or the element name is not valid as a C# identifier, you may get a run-time error. To avoid run-time errors, ensure that the Web service you consume does not contain element names that are C# keywords or invalid C# identifiers.

    For consuming webservice in BizTalk: Use BizTalk WCF Service Consuming Wizard 

    The BizTalk Adapter Framework provides a way to add adapter schemas and BizTalk types to BizTalk projects. The BizTalk WCF Service Consuming Wizard enables you to add WCF send adapters to a BizTalk project. For the WCF send adapters, you must select an existing metadata exchange (MEX) endpoint for send ports. Then you need to enter the information used to generate the schemas and types. When the wizard completes, the schemas and types necessary to consume WCF services are added to the BizTalk project. For reference see How to Use the BizTalk WCF Service Consuming Wizard to Consume a WCF Service.

    For consuming webservice in .NET: Add Service Reference->Add Web Reference or ServiceModel Metadata Utility Tool (Svcutil.exe)

    A Web reference is a generated proxy class that locally represents the exposed functionality of an XML Web service. The proxy class defines methods that represent the actual methods exposed by an XML Web service. When your application creates an instance of the proxy class, your application can call the XML Web service methods as if the XML Web service were a locally available component.

    For using ServiceModel Metadata Utility Tool (Svcutil.exe): Open Visual Studio Command Prompt and generate proxy using svcutil.exe tool as follows:

    svcutil http://localhost:4321/StudentService /out:StudentServiceProxy.cs

    Refer: http://www.codeproject.com/Articles/786601/Ways-to-generate-proxy-for-WCF-Service 

    You can also do Restful calls and consume the response using HttpWebRequest() and returning xml or json.

    For more information, please try to refer to:
    #Consume Web services Dynamically using HttpWebRequest:
    http://swagatblog.wordpress.com/2011/01/09/consume-web-services-dynamically-using-httpwebrequest/ 

    If a web service with no wsdl, using the HttpWebRequest() will the best way.
    Here is a example about no wsdl:
    http://stackoverflow.com/questions/1277212/how-to-call-a-web-service-with-no-wsdl-in-net


    Rachit Sikroria (Microsoft Azure MVP)

    Saturday, August 27, 2016 6:09 PM
    Moderator