You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-bus-relay/service-bus-relay-rest-tutorial.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,10 @@ To begin using the relay features in Azure, you must first create a service name
48
48
49
49
## Define a REST-based WCF service contract to use with Azure Relay
50
50
51
-
When you create a WCF REST-style service, you must define the contract. The contract specifies what operations the host supports. A service operation can be thought of as a web service method. Define a contract with a C++, C#, or Visual Basic interface. Each method in the interface corresponds to a specific service operation. Apply the [ServiceContractAttribute](/dotnet/api/system.servicemodel.servicecontractattribute) attribute to each interface, and apply the [OperationContractAttribute](/dotnet/api/system.servicemodel.operationcontractattribute) attribute to each operation. If a method in an interface that has the [ServiceContractAttribute](/dotnet/api/system.servicemodel.servicecontractattribute) doesn't have the [OperationContractAttribute](/dotnet/api/system.servicemodel.operationcontractattribute), that method isn't exposed. The code used for these tasks appears in the example following the procedure.
51
+
When you create a WCF REST-style service, you must define the contract. The contract specifies what operations the host supports. A service operation resembles a web service method. Define a contract with a C++, C#, or Visual Basic interface. Each method in the interface corresponds to a specific service operation. Apply the [ServiceContractAttribute](/dotnet/api/system.servicemodel.servicecontractattribute) attribute to each interface, and apply the [OperationContractAttribute](/dotnet/api/system.servicemodel.operationcontractattribute) attribute to each operation.
52
+
53
+
> [!TIP]
54
+
> If a method in an interface that has the [ServiceContractAttribute](/dotnet/api/system.servicemodel.servicecontractattribute) doesn't have the [OperationContractAttribute](/dotnet/api/system.servicemodel.operationcontractattribute), that method isn't exposed. The code used for these tasks appears in the example following the procedure.
52
55
53
56
The primary difference between a WCF contract and a REST-style contract is the addition of a property to the [OperationContractAttribute](/dotnet/api/system.servicemodel.operationcontractattribute): [WebGetAttribute](/dotnet/api/system.servicemodel.web.webgetattribute). This property enables you to map a method in your interface to a method on the other side of the interface. This example uses the [WebGetAttribute](/dotnet/api/system.servicemodel.web.webgetattribute) attribute to link a method to `HTTP GET`. This approach enables Service Bus to accurately retrieve and interpret commands sent to the interface.
54
57
@@ -92,7 +95,7 @@ Next, make the following code changes to the project:
92
95
...
93
96
```
94
97
95
-
1. Directly after the opening curly brace of the namespacedeclaration, defineanewinterfacenamed `IImageContract` andapplythe `ServiceContractAttribute` attributetotheinterfacewithavalueof `https://samples.microsoft.com/ServiceModel/Relay/RESTTutorial1`. The namespace value differs from the namespace that you use throughout the scope of your code. The namespace value is a unique identifier for this contract, and should have version information. For more information, see [Service Versioning](/dotnet/framework/wcf/service-versioning). Specifying the namespace explicitly prevents the default namespace value from being added to the contract name.
98
+
1. Directly after the opening curly brace of the namespacedeclaration, defineanewinterfacenamed `IImageContract` andapplythe `ServiceContractAttribute` attributetotheinterfacewithavalueof `https://samples.microsoft.com/ServiceModel/Relay/RESTTutorial1`.
@@ -101,6 +104,8 @@ Next, make the following code changes to the project:
101
104
}
102
105
```
103
106
107
+
The namespacevaluediffersfromthenamespacethatyouusethroughoutthescopeofyourcode. Thenamespacevalueisauniqueidentifierforthiscontract, andshouldhaveversioninformation. Formoreinformation, see [ServiceVersioning](/dotnet/framework/wcf/service-versioning). Specifyingthenamespaceexplicitlypreventsthedefaultnamespacevaluefrombeingaddedtothecontractname.
1. Tomakesurethattherunningservicecanfindtheimagefile, in **SolutionExplorer** right-clicktheimagefile, thenchoose **Properties**. In **Properties**, set **CopytoOutputDirectory** to **Copyifnewer**.
@@ -247,7 +254,7 @@ As with the previous steps, there's little difference between implementing a RES
247
254
}
248
255
```
249
256
250
-
This implementation uses `MemoryStream` to retrieve the image and prepare it for streaming to the browser. It starts the stream position at zero, declares the stream content as a jpeg, and streams the information.
257
+
This implementation uses `MemoryStream` to retrieve the image and prepare it for streaming to the browser. It starts the stream position at zero, declares the stream content as a *.jpg*, and streams the information.
251
258
252
259
1. Select **Build** > **Build Solution**.
253
260
@@ -293,7 +300,7 @@ As with the previous steps, there's little difference between implementing a RES
@@ -485,7 +492,7 @@ The following example shows the *App.config* file associated with the service.
485
492
486
493
## Host the REST-based WCF service to use Azure Relay
487
494
488
-
This section describes how to run a web service usingaconsoleapplicationwithWCFRelay. Acompletelistingofthecodewritteninthissectionisprovidedintheexamplefollowingtheprocedure.
495
+
This section describes how to run a web service usingaconsoleapplicationwithWCFRelay. Acompletelistingofthecodewritteninthissectionappearsintheexamplefollowingtheprocedure.
489
496
490
497
### Tocreateabaseaddressfortheservice
491
498
@@ -627,7 +634,7 @@ After building the solution, do the following to run the application:
627
634
628
635
Now that you've built an application that uses the Azure Relay service, see the following articles to learn more:
Copy file name to clipboardExpand all lines: articles/service-bus-relay/service-bus-relay-tutorial.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,7 @@ This tutorial describes how to build a WCF Relay client application and service
23
23
24
24
Working through this tutorial gives you an understanding of the steps to create a WCF Relay client and service application. Like their original WCF counterparts, a service is a construct that exposes one or more endpoints. Each endpoint exposes one or more service operations. The endpoint of a service specifies an address where the service can be found, a binding that contains the information that a client must communicate with the service, and a contract that defines the functionality provided by the service to its clients. The main difference between WCF and WCF Relay is that the endpoint is exposed in the cloud instead of locally on your computer.
25
25
26
-
After you work through the sequence of sections in this tutorial, you'll have a running service. You'll also have a client that can invoke the operations of the service. The first section describes how to set up an account. The next sections describe how to define a service that uses a contract, how to implement the service, and how to configure the service in code. They also describe how to host and run the service. The service is self-hosted and the client and service run on the same computer. You can configure the service by using either code or a configuration file.
27
-
28
-
The final three sections describe how to create a client application, configure the client application, and create and use a client that can access the functionality of the host.
26
+
After you work through the sequence of sections in this tutorial, you'll have a running service. You'll also have a client that can invoke the operations of the service.
29
27
30
28
You do the following tasks in this tutorial:
31
29
@@ -51,7 +49,7 @@ To complete this tutorial, you need the following prerequisites:
51
49
52
50
## Create a Relay namespace
53
51
54
-
The first step is to create a namespace, and to obtain a [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) key. A namespace provides an application boundary for each application exposed through the relay service. A SAS key is automatically generated by the system when a service namespace is created. The combination of service namespace and SAS key provides the credentials for Azure to authenticate access to an application.
52
+
The first step is to create a namespace, and to obtain a [Shared Access Signature (SAS)](../service-bus-messaging/service-bus-sas.md) key. A namespace provides an application boundary for each application exposed through the relay service. An SAS key is automatically generated by the system when a service namespace is created. The combination of service namespace and SAS key provides the credentials for Azure to authenticate access to an application.
1. Directlyafterthe `Microsoft.ServiceBus.Samples` namespacedeclaration, butwithinthenamespace, defineanewinterfacenamed `IEchoContract` andapplythe `ServiceContractAttribute` attributetotheinterfacewithanamespacevalueof `https://samples.microsoft.com/ServiceModel/Relay/`. The namespace value differs from the namespace that you use throughout the scope of your code. Instead, the namespace value is used as a unique identifier for this contract. Specifying the namespace explicitly prevents the default namespace value from being added to the contract name. Paste the following code after the namespace declaration:
88
+
1. Directlyafterthe `Microsoft.ServiceBus.Samples` namespacedeclaration, butwithinthenamespace, defineanewinterfacenamed `IEchoContract` andapplythe `ServiceContractAttribute` attributetotheinterfacewithanamespacevalueof `https://samples.microsoft.com/ServiceModel/Relay/`. Paste the following code after the namespace declaration:
Enter some text to send to the service application and press Enter. This text is sent to the service through the Echo service operation and appears in the service console window as in the following example output.
765
+
Enter some text to send to the service application and select Enter. This text is sent to the service through the Echo service operation and appears in the service console window as in the following example output.
766
766
767
767
`Echoing: My sample text`
768
768
769
769
The client application receives the return value of the `Echo` operation, which is the original text, and prints it to its console window. The following text is example output from the client console window.
770
770
771
771
`Server echoed: My sample text`
772
772
773
-
1. You can continue sending text messages from the client to the service in this manner. When you're finished, press Enter in the client and service console windows to end both applications.
773
+
1. You can continue sending text messages from the client to the service in this manner. When you're finished, select Enter in the client and service console windows to end both applications.
0 commit comments