Training
Module
Work with web services in Dynamics 365 Business Central - Training
Use SOAP and OData to read and update records, and handle UI interaction in Business Central.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
To configure a WCF service endpoint to be interoperable with ASP.NET Web service clients:
Use the System.ServiceModel.BasicHttpBinding type as the binding type for your service endpoint.
Do not use callback and session contract features or transaction behaviors on your service endpoint
You can optionally enable support for HTTPS and transport-level client authentication on the binding.
The following features of the BasicHttpBinding class require functionality beyond WS-I Basic Profile 1.1:
Message Transmission Optimization Mechanism (MTOM) message encoding controlled by the BasicHttpBinding.MessageEncoding property. Leave this property at its default value, which is WSMessageEncoding.Text to not use MTOM.
Message security controlled by the BasicHttpBinding.Security value provides WS-Security support compliant with WS-I Basic Security Profile 1.0. Leave this property at its default value, which is SecurityMode.Transport to not use WS-Security.
To make the metadata for a WCF service available to ASP.NET, use the Web service client generation tools: Web Services Description Language Tool (Wsdl.exe), Web Services Discovery Tool (Disco.exe), and the Add Web Reference feature in Visual Studio. Enable metadata publication. For more information, see Publishing Metadata Endpoints.
The following example code demonstrates how to add a WCF endpoint that is compatible with ASP.NET Web service clients in code and, alternatively, in a configuration file.
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
[ServiceContract]
public interface IEcho
{
[OperationContract]
string Echo(string s);
}
public class MyService : IEcho
{
public string Echo(string s)
{
return s;
}
}
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://localhost:8080/wcfselfhost/";
ServiceHost host = new ServiceHost(typeof(MyService), new Uri(baseAddress));
// Create a BasicHttpBinding instance
BasicHttpBinding binding = new BasicHttpBinding();
// Add a service endpoint using the created binding
host.AddServiceEndpoint(typeof(IEcho), binding, "echo1");
host.Open();
Console.WriteLine("Service listening on {0} . . .", baseAddress);
Console.ReadLine();
host.Close();
}
}
Imports System.Collections.Generic
Imports System.Text
Imports System.ServiceModel
Imports System.ServiceModel.Description
<ServiceContract()> _
Public Interface IEcho
<OperationContract()> _
Function Echo(ByVal s As String) As String
End Interface
Public Class MyService
Implements IEcho
Public Function Echo(ByVal s As String) As String Implements IEcho.Echo
Return s
End Function
End Class
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim baseAddress = "http://localhost:8080/wcfselfhost/"
Dim host As New ServiceHost(GetType(MyService), _
New Uri(baseAddress))
' Add a service endpoint using the created binding
With host
.AddServiceEndpoint(GetType(IEcho), _
New BasicHttpBinding(), _
"echo1")
.Open()
Console.WriteLine("Service listening on {0} . . .", _
baseAddress)
Console.ReadLine()
.Close()
End With
End Sub
End Class
<configuration>
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="HttpGetMetadata">
<endpoint address="echo2" contract="IEcho" binding="basicHttpBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Training
Module
Work with web services in Dynamics 365 Business Central - Training
Use SOAP and OData to read and update records, and handle UI interaction in Business Central.
Documentation
Specifying an Endpoint Address - WCF
Learn about an endpoint address, one part of a ServiceEndpoint in WCF. All communication with a WCF service occurs through its endpoints.
Learn more about: Addressing
Learn more about: Multiple Contracts