本文整理汇总了C#中System.ServiceModel.BasicHttpBinding类的典型用法代码示例。如果您正苦于以下问题:C# BasicHttpBinding类的具体用法?C# BasicHttpBinding怎么用?C# BasicHttpBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicHttpBinding类属于System.ServiceModel命名空间,在下文中一共展示了BasicHttpBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBasicBinding
public static BasicHttpBinding CreateBasicBinding(Uri uri)
{
BasicHttpBinding binding = new BasicHttpBinding()
{
CloseTimeout = TimeSpan.FromMinutes(1),
ReceiveTimeout = TimeSpan.FromMinutes(10),
SendTimeout = TimeSpan.FromMinutes(5),
AllowCookies = false,
BypassProxyOnLocal = false,
HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
MaxBufferSize = int.MaxValue,
MaxBufferPoolSize = 524288,
MaxReceivedMessageSize = int.MaxValue,
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = Encoding.UTF8,
TransferMode = TransferMode.Buffered,
UseDefaultWebProxy = true
};
var quotas = binding.ReaderQuotas;
quotas.MaxArrayLength =
quotas.MaxBytesPerRead =
quotas.MaxDepth =
quotas.MaxNameTableCharCount =
quotas.MaxStringContentLength = int.MaxValue;
binding.Security.Mode = string.Equals(uri.Scheme, "https", StringComparison.OrdinalIgnoreCase) ?
BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
return binding;
}
示例2: CoreServiceProvider
public CoreServiceProvider()
{
var binding = new BasicHttpBinding
{
MaxReceivedMessageSize = 10485760,
ReaderQuotas = new XmlDictionaryReaderQuotas
{
MaxStringContentLength = 10485760,
MaxArrayLength = 10485760
},
Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.TransportCredentialOnly,
Transport = new HttpTransportSecurity
{
ClientCredentialType = HttpClientCredentialType.Windows
}
}
};
string coreServiceUrl = ConfigurationManager.AppSettings[Constants.TRIDION_CME_URL] + "/webservices/CoreService2013.svc/basicHttp";
Console.WriteLine("Connect to CoreService " + coreServiceUrl);
EndpointAddress endpoint = new EndpointAddress(coreServiceUrl);
factory = new ChannelFactory<ICoreService>(binding, endpoint);
string userName = ConfigurationManager.AppSettings[Constants.USER_NAME];
string password = ConfigurationManager.AppSettings[Constants.PASSWORD];
factory.Credentials.Windows.ClientCredential = new NetworkCredential(userName, password);
Client = factory.CreateChannel();
UserData user = Client.GetCurrentUser();
Console.WriteLine("Connected as {0} ({1})", user.Description, user.Title);
}
示例3: RightNowService
public RightNowService(IGlobalContext _gContext)
{
// Set up SOAP API request to retrieve Endpoint Configuration -
// Get the SOAP API url of current site as SOAP Web Service endpoint
EndpointAddress endPointAddr = new EndpointAddress(_gContext.GetInterfaceServiceUrl(ConnectServiceType.Soap));
// Minimum required
BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding2.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
// Optional depending upon use cases
binding2.MaxReceivedMessageSize = 5 * 1024 * 1024;
binding2.MaxBufferSize = 5 * 1024 * 1024;
binding2.MessageEncoding = WSMessageEncoding.Mtom;
// Create client proxy class
_rnowClient = new RightNowSyncPortClient(binding2, endPointAddr);
BindingElementCollection elements = _rnowClient.Endpoint.Binding.CreateBindingElements();
elements.Find<SecurityBindingElement>().IncludeTimestamp = false;
_rnowClient.Endpoint.Binding = new CustomBinding(elements);
// Add SOAP msg inspector behavior
//_rnowClient.Endpoint.Behaviors.Add(new LogMsgBehavior());
// Ask the Add-In framework the handle the session logic
_gContext.PrepareConnectSession(_rnowClient.ChannelFactory);
// Set up query and set request
_rnowClientInfoHeader = new ClientInfoHeader();
_rnowClientInfoHeader.AppID = "Case Management Accelerator Services";
}
示例4: GetChannelFactory
private ChannelFactory<ISharedTextEditorC2S> GetChannelFactory(string host)
{
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress(host);
return new ChannelFactory<ISharedTextEditorC2S>(binding, endpoint);
}
示例5: FileTransferServiceProxy
public FileTransferServiceProxy()
{
this.m_BasicHttpBinding = new BasicHttpBinding();
this.m_EndpointAddress = new EndpointAddress(EndpointAddressUrl);
this.m_BasicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
this.m_BasicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
this.m_BasicHttpBinding.MaxReceivedMessageSize = 2147483647;
XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
readerQuotas.MaxArrayLength = 25 * 208000;
readerQuotas.MaxStringContentLength = 25 * 208000;
this.m_BasicHttpBinding.ReaderQuotas = readerQuotas;
this.m_ChannelFactory = new ChannelFactory<Contract.IFileTransferService>(this.m_BasicHttpBinding, this.m_EndpointAddress);
this.m_ChannelFactory.Credentials.UserName.UserName = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.UserName;
this.m_ChannelFactory.Credentials.UserName.Password = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.Password;
foreach (System.ServiceModel.Description.OperationDescription op in this.m_ChannelFactory.Endpoint.Contract.Operations)
{
var dataContractBehavior = op.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
}
this.m_FileTransferServiceChannel = this.m_ChannelFactory.CreateChannel();
}
示例6: Client
public Client(String URL)
{
BasicHttpBinding myBinding = new BasicHttpBinding();
EndpointAddress myEndpoint = new EndpointAddress(URL);
myChannelFactory = new ChannelFactory<Server.IServerService>(myBinding, myEndpoint);
comInterface = myChannelFactory.CreateChannel();
}
示例7: Main
static void Main()
{
// только не null, ибо возникнет исключение
//var baseAddress = new Uri("http://localhost:8002/MyService");
var host = new ServiceHost(typeof(MyContractClient));//, baseAddress);
host.Open();
//var otherBaseAddress = new Uri("http://localhost:8001/");
var otherHost = new ServiceHost(typeof(MyOtherContractClient));//, otherBaseAddress);
var wsBinding = new BasicHttpBinding();
var tcpBinding = new NetTcpBinding();
otherHost.AddServiceEndpoint(typeof(IMyOtherContract), wsBinding, "http://localhost:8001/MyOtherService");
otherHost.AddServiceEndpoint(typeof(IMyOtherContract), tcpBinding, "net.tcp://localhost:8003/MyOtherService");
//AddHttpGetMetadata(otherHost);
AddMexEndpointMetadata(otherHost);
otherHost.Open();
// you can access http://localhost:8002/MyService
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Host());
otherHost.Close();
host.Close();
// you can not access http://localhost:8002/MyService
}
示例8: TextMessageEncoder_WrongContentTypeResponse_Throws_ProtocolException
public static void TextMessageEncoder_WrongContentTypeResponse_Throws_ProtocolException()
{
ChannelFactory<IWcfService> factory = null;
IWcfService serviceProxy = null;
string testContentType = "text/blah";
Binding binding = null;
try
{
// *** SETUP *** \\
binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic));
serviceProxy = factory.CreateChannel();
// *** EXECUTE *** \\
Assert.Throws<ProtocolException>(() => { serviceProxy.ReturnContentType(testContentType); });
// *** VALIDATE *** \\
// *** CLEANUP *** \\
factory.Close();
((ICommunicationObject)serviceProxy).Close();
}
finally
{
// *** ENSURE CLEANUP *** \\
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
}
}
示例9: ServiceClientWrapper
public ServiceClientWrapper()
{
this.EndpointUri = UriProvider.GetNextUri();
// var binding = new BasicHttpBinding("BasicHttpBinding_IRemoteWorkerService");
var binding = new BasicHttpBinding();
this.client = new WSClient.RemoteWorkerServiceClient(binding, new EndpointAddress(this.EndpointUri));
}
示例10: Create
public Binding Create(Endpoint serviceInterface)
{
if (Utilities.Utilities.GetDisableCertificateValidation().EqualsCaseInsensitive("true"))
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
{
Name = serviceInterface.EndpointName,
AllowCookies = false,
HostNameComparisonMode = serviceInterface.HostNameComparisonMode.ParseAsEnum(HostNameComparisonMode.StrongWildcard),
MaxBufferPoolSize = serviceInterface.MaxBufferPoolSize,
MaxReceivedMessageSize = serviceInterface.MaxReceivedSize,
MessageEncoding = serviceInterface.MessageFormat.ParseAsEnum(WSMessageEncoding.Text),
TextEncoding = Encoding.UTF8,
ReaderQuotas = XmlDictionaryReaderQuotas.Max,
BypassProxyOnLocal = true,
UseDefaultWebProxy = false
};
if (ConfigurationManagerHelper.GetValueOnKey("stardust.UseDefaultProxy") == "true")
{
binding.BypassProxyOnLocal = false;
binding.UseDefaultWebProxy = true;
}
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
return binding;
}
示例11: Unrecordingvoters
public ActionResult Unrecordingvoters()
{
var unrecordingCitizens = new List<NufusMudurluguService.Citizen>();
var myBinding = new BasicHttpBinding();
var myEndpoint = new EndpointAddress("http://192.168.1.222:9999/TCNufusMudurlugu/GetCitizens");
var myChannelFactory = new ChannelFactory<IService1>(myBinding, myEndpoint);
NufusMudurluguService.IService1 client = null;
try
{
client = myChannelFactory.CreateChannel();
var citizens = client.GetCitizens();
foreach (var citizen in citizens)
{
if (!m_internetDc.Voters.Any(f => f.IdentityNo == citizen.IdentityNo))
{
unrecordingCitizens.Add(citizen);
}
}
ViewData["Unrecording"] = unrecordingCitizens;
}
catch (Exception exp)
{
}
return View();
}
示例12: CreateServiceHost
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
try
{
String factoryClass = this.GetType().Name;
String endpointName =
String.Format("{0}HttpEndpoint",
factoryClass.Substring(0, factoryClass.IndexOf("ServiceHostFactory")));
String externalEndpointAddress =
string.Format("http://{0}/{1}.svc",
RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[endpointName].IPEndpoint,
serviceType.Name);
var host = new ServiceHost(serviceType, new Uri(externalEndpointAddress));
var basicBinding = new BasicHttpBinding(String.Format("{0}Binding", serviceType.Name));
foreach (var intf in serviceType.GetInterfaces())
host.AddServiceEndpoint(intf, basicBinding, String.Empty);
return host;
}
catch (Exception e)
{
Trace.TraceError("ServiceFactory: {0}{4}Exception: {1}{4}Message: {2}{4}Trace: {3}",
this.GetType().Name,
e.GetType(),
e.Message,
e.StackTrace,
Environment.NewLine);
throw new SystemException(String.Format("Unable to activate service: {0}", serviceType.FullName), e);
}
}
示例13: GetHttpBinding
private Binding GetHttpBinding()
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
return binding;
}
示例14: TimetableServiceConfiguration
public TimetableServiceConfiguration()
{
BasicHttpBinding httpBinding = new BasicHttpBinding();
TimetableServiceClient =
new TimetableServiceClient(httpBinding, EndPoints.TimetableService);
}
示例15: DefaultSettings_Echo_RoundTrips_String
public static void DefaultSettings_Echo_RoundTrips_String()
{
ChannelFactory<IWcfService> factory = null;
IWcfService serviceProxy = null;
string testString = "Hello";
Binding binding = null;
try
{
// *** SETUP *** \\
binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
factory = new ChannelFactory<IWcfService>(binding, new EndpointAddress(Endpoints.HttpBaseAddress_Basic));
serviceProxy = factory.CreateChannel();
// *** EXECUTE *** \\
string result = serviceProxy.Echo(testString);
// *** VALIDATE *** \\
Assert.True(result == testString, String.Format("Error: expected response from service: '{0}' Actual was: '{1}'", testString, result));
// *** CLEANUP *** \\
factory.Close();
((ICommunicationObject)serviceProxy).Close();
}
finally
{
// *** ENSURE CLEANUP *** \\
ScenarioTestHelpers.CloseCommunicationObjects((ICommunicationObject)serviceProxy, factory);
}
}