Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0"?>
- <configuration>
- <system.serviceModel>
- <services>
- <service name="WcfService3.Service1" behaviorConfiguration="WcfService3.Service1Behavior">
- <!-- Service Endpoints -->
- <endpoint address="" binding="wsHttpBinding" contract="WcfService3.IService1">
- <identity>
- <dns value="localhost"/>
- </identity>
- </endpoint>
- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
- </service>
- </services>
- <behaviors>
- <serviceBehaviors>
- <behavior name="WcfService3.Service1Behavior">
- <serviceMetadata httpGetEnabled="true"/>
- <serviceDebug includeExceptionDetailInFaults="false"/>
- </behavior>
- </serviceBehaviors>
- </behaviors>
- </system.serviceModel>
- </configuration>
- namespace WcfService3
- {
- [ServiceContract]
- public interface IService1
- {
- [OperationContract]
- string GetData(string username, string password);
- }
- [DataContract]
- public class Data
- {
- [DataMember]
- public string Username { get; set; }
- [DataMember]
- public string Password { get; set; }
- }
- }
- namespace WcfService3
- {
- public class Service1 : IService1
- {
- [WebInvoke(Method = "GET",
- RequestFormat = WebMessageFormat.Json,
- ResponseFormat = WebMessageFormat.Json,
- UriTemplate = "data/{user}/{pass}")]
- public string GetData(string user, string pass)
- {
- Data UserData = new Data()
- {
- Username = user,
- Password = pass
- };
- MemoryStream stream = new MemoryStream();
- DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Data));
- ser.WriteObject(stream, UserData);
- string json = Encoding.Default.GetString(stream.ToArray());
- return json;
- }
- }
- }
- <services>
- <service name="WcfService3.Service1" behaviorConfiguration="WcfService3.Service1Behavior">
- <!-- Service Endpoints -->
- <endpoint address="" binding="webHttpBinding" behaviorConfiguration="webBehavior" contract="WcfService3.IService1">
- <identity>
- <dns value="localhost"/>
- </identity>
- </endpoint>
- <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
- </service>
- </services>
- <endpointBehaviors>
- <behavior name="webBehavior">
- <webHttp />
- </behavior>
- </endpointBehaviors>
- namespace WcfService3
- {
- public class Service1 : IService1
- {
- [WebInvoke(Method = "GET",
- RequestFormat = WebMessageFormat.Json,
- ResponseFormat = WebMessageFormat.Json,
- UriTemplate = "data/{user}/{pass}")]
- public Data GetData(string user, string pass)
- {
- Data UserData = new Data()
- {
- Username = user,
- Password = pass
- };
- return UserData;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement