Enable HTTP and HTTPS on a custom binding - c#

Is it possible to add HTTPS and HTTP support to a custom binding like this?
<customBinding>
<binding name="RS2010Soap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Ntlm"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
Endpoint:
<endpoint address="https://Server1/ReportServer/ReportService2010.asmx"
binding="customBinding" bindingConfiguration="RS2010Soap12"
contract="Program.ReportingService2010Soap"
name="RS2010Soap12" />

No, you'll have to create two bindings and expose two endpoints for your service.

Related

Could not find endpoint element with name '' and contract '' in the ServiceModel client configuration section

I have tried days to solve this damn error. I am calling the same service in asp.net and it works fine, but when I call it in a sharepoint solution it does not work. This is the error that I receive.
Could not find endpoint element with name 'WeatherSoap' and contract 'WeatherService.WeatherSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
this is my app.config in the library:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WeatherSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="WeatherSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
binding="basicHttpBinding" bindingConfiguration="WeatherSoap"
contract="WeatherService.WeatherSoap" name="WeatherSoap" />
<endpoint address="http://wsf.cdyne.com/WeatherWS/Weather.asmx"
binding="customBinding" bindingConfiguration="WeatherSoap12"
contract="WeatherService.WeatherSoap" name="WeatherSoap12" />
</client>
</system.serviceModel>
This is my C# code
WeatherService.WeatherSoapClient client = new WeatherService.WeatherSoapClient("WeatherSoap");
WeatherService.WeatherReturn result = client.GetCityWeatherByZIP(txtZip.Text);
this is the code that I use in code behind in both sharepoint visual web part and in asp.net web page. The strange thing is that it works fine in asp.net but not in sharepoint.
I'm calling the service in a same project.
Look at this link: http://msdn.microsoft.com/en-us/library/ff647110.aspx
You may need to add configure the wcf endpoint programmatically for the sharepoint web part.

How do i call webservice from windows service

I have a windows service from which I am trying to call a method under remote webservice but I am getting error that "Could not find default endpoint element that references contract 'MyWebService.BookingCitySoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."
Following is the code for that
.cs File
MyWebService.BookingCitySoapClient ws = new MyWebService.BookingCitySoapClient();
ws.CallBookStatus();
ws.CallCanStatus();
App.config
<bindings>
<basicHttpBinding>
<binding name="BookingCitySoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:51317/Web/BookingCity.asmx"
binding="basicHttpBinding" bindingConfiguration="BookingCitySoap"
contract="MyWebService.BookingCitySoap" name="BookingCitySoap" />
</client>

Invalid operation Exception while instantiating object of asmx web service

I am trying to incorporate .asmx web service in my application.
For this I
1. created a Class library project.
2. Added service reference with the given wsdl
3. An app.Config was automatically created. The app.config that is
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="UploadWebServiceSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="UploadWebServiceSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:xxxx/xxx/UploadWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="UploadWebServiceSoap"
contract="ServiceReference1.UploadWebServiceSoap" name="UploadWebServiceSoap" />
<endpoint address="http://localhost:xxxx/xxx/UploadWebService.asmx"
binding="customBinding" bindingConfiguration="UploadWebServiceSoap12"
contract="ServiceReference1.UploadWebServiceSoap" name="UploadWebServiceSoap12" />
</client>
</system.serviceModel>
After all the set up, I tried calling the methods in web-service in my function.
UploadWebServiceSoapClient dpcClient = new UploadWebServiceSoapClient();
This is where is get an error
Could not find default endpoint element that references contract 'ServiceReference1.UploadWebServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
Can anyone please tell me why I am getting this error. Also, I understand the binding created basicHttpBinding but what is and an endpoint for the same was created
It looks as if you've created service reference multiple times. First you created ServiceReference1 and then DPCServiceReference. You should change your endpoint configuration:
contract="ServiceReference1.UploadWebServiceSoap"
to
contract="DPCServiceReference.UploadWebServiceSoap"
You have 2 lines with this error.
If this won't help try deleting customBinding and endpoint with Soap12.

Service Reference Security Header

I am getting the following error when trying to use a service reference:
Urgent: wsdoallreceiver incoming message does not contain required security header
My configuration file has the following:
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ProjectServiceSOAP11Binding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<customBinding>
<binding name="ProjectServiceSOAP12Binding">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="(address here)"
binding="basicHttpBinding" bindingConfiguration="ProjectServiceSOAP11Binding"
contract="ProjectService.ProjectServicePortType" name="ProjectServiceSOAP11port_http" />
<endpoint address="(address here)"
binding="customBinding" bindingConfiguration="ProjectServiceSOAP12Binding"
contract="ProjectService.ProjectServicePortType" name="ProjectServiceSOAP12port_http" />
</client>
</system.serviceModel>
</configuration
I am attempting to authenticate like so:
ProjectServicePortTypeClient myProjectClient = new ProjectServicePortTypeClient("ProjectServiceSOAP11Binding");
myProjectClient.ClientCredentials.SupportInteractive = true;
myProjectClient.ClientCredentials.UserName.UserName = myLogInEmail;
myProjectClient.ClientCredentials.UserName.Password = myPassword;
Is there an obvious mistake I am making?
after doing hours of additional research, i've determined i probably need to do this:
http://msdn.microsoft.com/en-us/library/ms731075.aspx

Web Service Creating Instance Problem -> Could not find default endpoint element that references contract 'MyWebService.ClassName'

i want to use the below Web-Service :
https://acquirer.sb24.com/ref-payment/ws/ReferencePayment?WSDL
and builded config file after adding ->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PaymentIFBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="PaymentIFBinding1" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://acquirer.sb24.com:443/ref-payment/ws/ReferencePayment"
binding="basicHttpBinding" bindingConfiguration="PaymentIFBinding"
contract="SB24Service.PaymentIF" name="PaymentIFPort" />
</client>
</system.serviceModel>
</configuration>
i want to call verifyTransaction method of this WebService :
PaymentIFClient pic = new PaymentIFClient();
double pic_result = pic.verifyTransaction(str1, str2);
but the first line throws the below error :
Could not find default endpoint element that references contract
'SB24Service.PaymentIF' in the ServiceModel client configuration
section. This might be because no configuration file was found for
your application, or because no endpoint element matching this
contract could be found in the client element.
EDIT :
"This error can arise if you are calling the service in a class
library and calling the class library from another project." -> My
Situation is like this ...
what should i change i configuration file ?
thanks in advance
Editing wcf configuration by hand is tricky, as there are many sections that need to be correct and correctly reference each other. Try opening your app.config file in SvcConfigEditor (also available from the Tools menu in Viusal Studio). It is way easier to get things correct when having GUI help on what to do.

Categories