wcf adding issue? - c#

I'm working with N-tier architecture. I have a WCF service in a hosting layer. I added services file successfully in here.
Problem is when I add the service in an application. It adds the service to the project successfully, but when I call the service I can't call it from my application class but when I rebuild project I haven't any issue.
On the other hand if I add the same service to another project I haven't a problem and everything is ok.
Has anyone encountered this?
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="true" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:5555/MyService.svc" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IMyService" contract="ServiceReference1.IMyService"
name="WSHttpBinding_IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>

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.

WCF Error Zero Application Endpoints when using Remote Client

I have a published WCF Service running correctly and verified by pulling up the wsdl? screen.
However, when I try to access any methods using code from a separate website I get the following error:
Service 'wcfServiceFromCaps.AgentWebAppServiceClient' has zero application(non- infrastructure) endpoints. This might be because no configuration file was found for your application
[ServiceContract]
interface IAgentWebAppService
{
[OperationContract]
[FaultContract(typeof(ServiceData))]
void DoWork();
[OperationContract]
[FaultContract(typeof(ServiceData))]
String GetAgentPicURLUsingStation(string station);
}
Client WebConfig
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IAgentWebAppService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://myfulladdresshere:87/AgentWebAppService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IAgentWebAppService"
contract="IAgentWebAppService" name="WSHttpBinding_IAgentWebAppService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Client CS
AgentWebAppServiceClient newWcf = new AgentWebAppServiceClient();
try
{
string newstring = newWcf.GetAgentPicURLUsingStation(this.Phone);
newpicurl = newstring;
}
catch (FaultException<wcfServiceFromCaps.ServiceData> Fex)
{
....
}
What am I missing?
Update!**
I resolved it by cleaning everything up and recreating from scratch.
Now I'm getting the following message:
Cannot open Database "dbname" requested by the login. The login
failed. Login failed for user "Servername$"

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>

Referenced name for my WCF service - Customers.svc or CustomersWcfDS.svc?

I have the following Visual Studio Web application structure:
CustomerManagement\
- Services
- Customers.aspx
- Customers.aspx.cs
- CustomersWcfDS.svc
- Default.aspx
- web.config
The following code is inside the <configuration> in the web.config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ICustomers" 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:1112/Services/Customers.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICustomers" contract="CustomersService.ICustomers" name="BasicHttpBinding_ICustomers" />
</client>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
I build the project and enter the following URL but there is no reactions.
http://localhost:1112/Services/Customers.svc
I also tried the following:
http://localhost:1112/Services/CustomersWcfDS.svc
and also
http://localhost:1110/Services/Customers.svc
and
http://localhost:1110/Services/CustomersWcfDS.svc
(The port 1110 was tested because of the Project Properties Port number was set to 1110.)
but it still fail to display something similar like the following illustration
So, is there any expert that can advise me where have my WCF service URL gone to?
Hi based on your image,
I think you have renamed the service name as Customers.svc . But still it refering to the previous one. What you can do is try to find the "SimpleService.svc" in your entire solution
and rename it as Customers.svc. If you have any problem put it as a comment.

WCF Service with large parameters

I've looked at a number of similar topics on SO, but haven't found one that helps with this.
Have a WCF service that takes in XML to process. The XML file I'm reading from is ~600K.
The call works for small xml files (most of the time), but on the larger files I get the error:
System.ServiceModel.Security.MessageSecurityException:
An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
where the inner exception is:
System.ServiceModel.FaultException:
The message could not be processed. This is most likely because the action 'http://tempuri.org/ISapListener/ProcessSapRoles' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
Like I say... it works for small files, and my open, send, receive, close, and inactivity timeouts are all set to 10 minutes. It fails in about 20-30 seconds.
Also, the clock on the server and client are perfectly in sync (I've seen that posted as an answer).
My config files as they currently stand (I've played with a lot of settings):
Server:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_Custom" closeTimeout="00:00:10"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:10:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false"
maxReceivedMessageSize="1024768"
maxBufferPoolSize="1024768" >
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="CSA.GS3.Services.SapListenerBehavior"
name="CSA.GS3.Services.SapListener">
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="wsHttpBinding_Custom"
contract="CSA.GS3.Services.ISapListener">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CSA.GS3.Services.SapListenerBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Client:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ISapListener1"
closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false"
maxBufferPoolSize="1024768"
maxReceivedMessageSize="1024768">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://gs3-test.us.tycoelectronics.com/SapListener/SapListener.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISapListener1"
contract="Gs3TestSapListener.ISapListener"
name="WSHttpBinding_ISapListener1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
I do have tracing enabled on the service, but I can't make sense out of the log files.
Other exceptions I've received while playing with the config settings:
System.ServiceModel.Security.SecurityNegotiationException
Secure channel cannot be opened because security negotiation with the remote endpoint has failed.
and
System.ServiceModel.ServiceActivationException
The requested service, 'http://../SapListener.svc' could not be activated.
If you think being able to make sense out of log files will help here, use svcTraceViewer. Just make sure you've actually set up tracing correctly. I have an article on my blog about this.
svcTraveViewer Debugging WCF Services
As regards large payloads, you may want to take a look at this MSDN article.
http://msdn.microsoft.com/en-us/library/ms733742.aspx
In particular Streaming Data.
System.ServiceModel.ServiceActivationException
The requested service, 'http://../SapListener.svc' could not be activated.
This could be a compilation error ou invalid configuration.
Is it WCF 4.0? Then you could remove your custom configuration and use automatic bindings. I also suggest you to try a binding other than wsHttpBinding, like basicHttpBinding.
I was able to get this to work with the following configuration:
Server:
<bindings>
<wsHttpBinding>
<binding name="wsHttpBinding_Custom"
closeTimeout="00:10:00"
openTimeout="00:10:00"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
maxReceivedMessageSize="2097152"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2097152" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
Client:
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ISapListener1" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
The only difference I can see is that I bumped up the maxReceivedMessageSize and maxBufferPoolSize... maybe I'm missing something else? If that was the issue, then the problem was that my overhead for the call was adding an additional 400+K to the 600K xml data I was sending
If possible and acceptable to client, you can break down the file into smaller chunks and send across, provided you don't have digital certificate etc and sorting options at client side.

Categories