本文整理汇总了C#中System.ServiceModel.BasicHttpBinding类的典型用法代码示例。如果您正苦于以下问题:C# BasicHttpBinding类的具体用法?C# BasicHttpBinding怎么用?C# BasicHttpBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicHttpBinding类属于System.ServiceModel命名空间,在下文中一共展示了BasicHttpBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:aries544,项目名称:eXpand,代码行数:34,代码来源:BindingFactory.cs
示例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);
}
开发者ID:mitza13,项目名称:yet-another-tridion-blog,代码行数:35,代码来源:CoreServiceClient.cs
示例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";
}
开发者ID:glitch11,项目名称:Accelerators,代码行数:31,代码来源:RightNowService.cs
示例4: GetChannelFactory
private ChannelFactory<ISharedTextEditorC2S> GetChannelFactory(string host)
{
var binding = new BasicHttpBinding();
var endpoint = new EndpointAddress(host);
return new ChannelFactory<ISharedTextEditorC2S>(binding, endpoint);
}
开发者ID:robstoll,项目名称:shared-text-editor,代码行数:7,代码来源:ClientServerCommunication.cs
示例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();
}
开发者ID:WilliamCopland,项目名称:YPILIS,代码行数:29,代码来源:FileTransferServiceProxy.cs
示例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();
}
开发者ID:kimpers,项目名称:school_work,代码行数:7,代码来源:Client.cs
示例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
}
开发者ID:Helen1987,项目名称:edu,代码行数:32,代码来源:Program.cs
示例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);
}
}
开发者ID:weshaggard,项目名称:wcf,代码行数:29,代码来源:TextEncodingTests.cs
示例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));
}
开发者ID:pbazydlo,项目名称:NetReduce,代码行数:7,代码来源:ServiceClientWrapper.cs
示例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;
}
开发者ID:JonasSyrstad,项目名称:Stardust,代码行数:26,代码来源:WindowsAuthenticatedWsBindingCreator.cs
示例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();
}
开发者ID:kirti-zare,项目名称:EOS,代码行数:26,代码来源:StatisticsController.cs
示例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);
}
}
开发者ID:jimoneil,项目名称:Azure-Photo-Mosaics,代码行数:32,代码来源:AzureServiceHostFactory.cs
示例13: GetHttpBinding
private Binding GetHttpBinding()
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
return binding;
}
开发者ID:RecordLion,项目名称:information-lifecycle-sdk,代码行数:7,代码来源:DefaultSecurityTokenRequestor.cs
示例14: TimetableServiceConfiguration
public TimetableServiceConfiguration()
{
BasicHttpBinding httpBinding = new BasicHttpBinding();
TimetableServiceClient =
new TimetableServiceClient(httpBinding, EndPoints.TimetableService);
}
开发者ID:PatrykOlejniczak,项目名称:WPK.TransportSystem,代码行数:7,代码来源:TimetableServiceConfiguration.cs
示例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);
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:30,代码来源:BasicHttpBindingTests.cs
示例16: CreateChannel
public void CreateChannel()
{
Binding binding;
EndpointAddress endpointAddress;
bool useAuth = !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);
if (IsLocal(ServerName))
{
endpointAddress = new EndpointAddress("net.pipe://localhost/MPExtended/TVAccessService");
binding = new NetNamedPipeBinding { MaxReceivedMessageSize = 10000000 };
}
else
{
endpointAddress = new EndpointAddress(string.Format("http://{0}:4322/MPExtended/TVAccessService", ServerName));
BasicHttpBinding basicBinding = new BasicHttpBinding { MaxReceivedMessageSize = 10000000 };
if (useAuth)
{
basicBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
basicBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
}
basicBinding.ReaderQuotas.MaxStringContentLength = 5*1024*1024; // 5 MB
binding = basicBinding;
}
binding.OpenTimeout = TimeSpan.FromSeconds(5);
ChannelFactory<ITVAccessService> factory = new ChannelFactory<ITVAccessService>(binding);
if (factory.Credentials != null && useAuth)
{
factory.Credentials.UserName.UserName = Username;
factory.Credentials.UserName.Password = Password;
}
TvServer = factory.CreateChannel(endpointAddress);
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:31,代码来源:SlimTVMPExtendedProvider.cs
示例17: MainPageLoaded
void MainPageLoaded(object sender, RoutedEventArgs e)
{
// Simple Version
var basicHttpBinding = new BasicHttpBinding();
var endpointAddress = new EndpointAddress("http://localhost:50738/UserGroupEvent.svc");
var userGroupEventService = new ChannelFactory<IAsyncUserGroupEventService>(basicHttpBinding, endpointAddress).CreateChannel();
AsyncCallback asyncCallBack = delegate(IAsyncResult result)
{
var response = ((IAsyncUserGroupEventService)result.AsyncState).EndGetUserGroupEvent(result);
Dispatcher.BeginInvoke(() => SetUserGroupEventData(response));
};
userGroupEventService.BeginGetUserGroupEvent("123", asyncCallBack, userGroupEventService);
// Deluxe Variante mit eigenem Proxy
var channel = new UserGroupEventServiceProxy("BasicHttpBinding_IAsyncUserGroupEventService").Channel;
channel.BeginGetUserGroupEvent("123", ProcessResult, channel);
// Variante mit Faulthandler
using (var scope = new OperationContextScope((IContextChannel)channel))
{
var messageHeadersElement = OperationContext.Current.OutgoingMessageHeaders;
messageHeadersElement.Add(MessageHeader.CreateHeader("DoesNotHandleFault", "", true));
channel.BeginGetUserGroupEventWithFault("123", ProcessResultWithFault, channel);
}
}
开发者ID:sven-s,项目名称:SilverlightErfahrungsbericht,代码行数:26,代码来源:MainPage.xaml.cs
示例18: CreateProductManager
public static ProductManagerClient CreateProductManager()
{
BasicHttpBinding wsd = new BasicHttpBinding();
wsd.Name = "WSHttpBinding_IProductManager";
wsd.SendTimeout = new TimeSpan(0,5,0);
wsd.MessageEncoding = WSMessageEncoding.Mtom;
wsd.AllowCookies = false;
wsd.BypassProxyOnLocal = false;
wsd.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
wsd.TextEncoding = Encoding.UTF8;
wsd.TransferMode = TransferMode.Buffered;
wsd.UseDefaultWebProxy = true;
wsd.MaxReceivedMessageSize = 1048576 * 30; // 30 mb
wsd.MaxBufferSize = 1048576 * 30;
wsd.Security.Mode = BasicHttpSecurityMode.None;
wsd.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
wsd.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
wsd.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
wsd.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
wsd.Security.Transport.Realm = string.Empty;
Uri baseAddress = new Uri("http://www.halan.se/service/ProductManager.svc/mtom");
EndpointAddress ea = new EndpointAddress(baseAddress); // EndpointIdentity.CreateDnsIdentity("localhost"));
return new ProductManagerClient(wsd, ea); //new ProductManagerClient("BasicHttpBinding_IProductManager");
}
开发者ID:jrgcubano,项目名称:ServiceBusMQManager,代码行数:27,代码来源:HalanServices.cs
示例19: CreateServiceClient
public static MixObjectsSoapClient CreateServiceClient()
{
var endpointAddr = new EndpointAddress(new Uri(Application.Current.Host.Source, Page.ServiceUrl));
var binding = new BasicHttpBinding();
var ctor = typeof(MixObjectsSoapClient).GetConstructor(new Type[] { typeof(Binding), typeof(EndpointAddress) });
return (MixObjectsSoapClient)ctor.Invoke(new object[] { binding, endpointAddr });
}
开发者ID:wenysky,项目名称:dnt31-lite,代码行数:7,代码来源:Utils.cs
示例20: GetServiceClient
public static PrimeSuiteServiceClient GetServiceClient(string IP)
{
string sMethodFullName = "Services." + System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
string sIP = IP;
string sServiceURL = "http://" + sIP + "/PrimeSuiteAPI/APIv1.0/PrimeSuiteAPI.svc";
System.ServiceModel.EndpointAddress oEndpointAddress = new System.ServiceModel.EndpointAddress(sServiceURL);
System.ServiceModel.BasicHttpBinding oBasicBinding = new System.ServiceModel.BasicHttpBinding();
oBasicBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
//"5242880" = 5MB
oBasicBinding.ReaderQuotas.MaxDepth = 2147483647;
oBasicBinding.ReaderQuotas.MaxArrayLength = 2147483647;
oBasicBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
oBasicBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
oBasicBinding.MaxBufferSize = 2147483647;
oBasicBinding.MaxReceivedMessageSize = 2147483647;
PrimeSuiteServiceClient client = new PrimeSuiteServiceClient(oBasicBinding, oEndpointAddress);
ModifyDataContractSerializerBehavior(client.Endpoint);
return (client);
}
catch (Exception ex)
{
//Throw New Exception("Error in " & sMethodFullName & ":" & vbNewLine & ex.Message & vbNewLine)
throw ex;
}
}
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:31,代码来源:HelperClass.cs
注:本文中的System.ServiceModel.BasicHttpBinding类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论