From my silverlight 4.0 application. I can access the WCF File easily but when moved to https, I can't access the WCF Service. The error details are following:
An unknown error occurred. Please contact your system Administrator for more information.
An exception occurred during the operation, making the result invalid. Check InnerException for exception details.
at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at FileSearch.SearchServices.GetTypeofFileDetailedCompletedEventArgs.get_Result()
at FileSearch.Home.<SearchButton_Click>b__0(Object s, GetTypeofFileDetailedCompletedEventArgs ea)
at FileSearch.SearchServices.SearchServiceClient.OnGetTypeofFileDetailedCompleted(Object state)
I have seen different posts regarding this issue, but nothing is pointing me in a proper direction.
Here are the details regarding my web.config file for the web application that hosts the silverlight application as well as the WCF Service.
<services>
<service name="FileSearch.Web.Services.SearchService">
<endpoint address="" binding="customBinding" bindingConfiguration="FileSearch.Web.Services.SearchService.customBinding0" contract="FileSearch.Web.Services.SearchService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
and here is the servicerefernce.clientconfig file:
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_SearchService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="../Services/SearchService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_SearchService"
contract="SearchServices.SearchService" name="CustomBinding_SearchService" />
</client>
</system.serviceModel>
</configuration>
UPDATE:
I've received answers to run the service in the https mode only. I want to run the service in both http and https modes.
any ideas regarding this ?
Specify two endpoints one with secured transport and one without it.
try adding
<security mode="Transport" />
in you service config file. this should be nested inside the binding node.
Check out the security mode configuration section in this article.
For supporting Https scheme, you'd need to change transport to <httpsTransport>. I see you're using <httpTransport>.
Related
Lately in all my new web applications I have been adding web services as service references rather than web references. Most of our web services were designed as asmx web services.
After adding the service reference my web.config always looks like this:
<bindings>
<basicHttpBinding>
<binding name="UserSoap" />
</basicHttpBinding>
<customBinding>
<binding name="UserSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="{{service URL}}" binding="basicHttpBinding"
bindingConfiguration="UserSoap" contract="User.UserSoap"
name="UserSoap" />
<endpoint address="{{service URL}}" binding="customBinding"
bindingConfiguration="UserSoap12" contract="User.UserSoap"
name="UserSoap12" />
</client>
Then my application gives this error when I try to consume it:
An endpoint configuration section for contract 'User.UserSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
I have been manually removing one of the endpoints, but now I want to know how to fix this.
Any ideas on how I can prevent this from happening, or why is this happening?
If you want to remove SOAP 1.2 support for your service, you would include the following in your web.config:
<configuration>
<system.web>
<webServices >
<protocols>
<remove name="HttpSoap12"/>
</protocols>
</webServices>
</system.web>
</configuration>
Add or remove SOAP 1.2 for ASMX services
Otherwise, you'll need to access with endpoint name.
var service = new User.UserSoapClient("UserSoap")
So I have a web service service reference that works localhost and can be pinged from its production url but I can't get access to it via the Service Reference call in production. I believe the issue is my firewall . I have two websites on the same server each with their own dedicated IP address. I am trying to call the web service on the second website from the first website. If I open a browser on my production server I cannot navigate to either website.
Error Description:There was no endpoint listening at http://[209.112.245.103]/Services/OfferService.asmx that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Inner Exception:Unable to connect to the remote server
The calling website is on the same server (different IP of course) and is calling the web service via a service reference:
Dim offerService As New ServiceReferenceOffer.OfferServiceSoapClient("OfferServiceSoap")
offerService.BroadcastOfferChange(offer.PropertyID, offer.OfferID, offer.ResultResponse)
And my web.config contains the following service endpoint information:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="OfferServiceSoap" />
<binding name="ConversationServiceSoap" />
</basicHttpBinding>
<customBinding>
<binding name="OfferServiceSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
<binding name="ConversationServiceSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://209.112.245.103/Services/ConversationService.asmx"
binding="basicHttpBinding" bindingConfiguration="ConversationServiceSoap"
contract="ServiceReferenceConversation.ConversationServiceSoap"
name="ConversationServiceSoap" />
<endpoint address="http://209.112.245.103/Services/ConversationService.asmx"
binding="customBinding" bindingConfiguration="ConversationServiceSoap12"
contract="ServiceReferenceConversation.ConversationServiceSoap"
name="ConversationServiceSoap12" />
<endpoint address="http://209.112.245.103/Services/OfferService.asmx"
binding="basicHttpBinding" bindingConfiguration="OfferServiceSoap"
contract="ServiceReferenceOffer.OfferServiceSoap" name="OfferServiceSoap" />
<endpoint address="http://209.112.245.103/Services/OfferService.asmx"
binding="customBinding" bindingConfiguration="OfferServiceSoap12"
contract="ServiceReferenceOffer.OfferServiceSoap" name="OfferServiceSoap12" />
</client>
</system.serviceModel>
Your configurations are correct. I just accessed your server and everything went fine (so it's not code related).
Since the site and the website are in the same server, you may need to use a different IP or address to access the wcf (try 127.0.0.1, localhost or an internal server ip).
I have a WCF service, which has a method with the following signature:
object GetCommand(Guid apiKey, SocialService service, string name, object argument);
The reason it's working with objects as both the return type and last argument, is because it should be possible to pass any type as argument and return any type.
Anyway, I'm passing an object, which contains the following property:
public byte[] Photo { get; set; }
To enable large messages, I'd like to start using Mtom, while I was previously using plain-text as MessageEncoding type.
Problem is, I want it to be backwards compatible, so current already-configures clients should keep using plain-text encoding, while new clients should be able to use Mtom via the web.config.
My question is: is it possible to keep using plain-text as MessageEncoding by default (existing clients) and offer Mtom encoding as well side-by-side?
I've tried some things with the configuration, like defining multiple endpoints with different binding-configurations, but I can't get it to work:
Server
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpTextBinding_SocialProxy" />
<binding name="BasicHttpMtomBinding_SocialProxy" maxReceivedMessageSize="5242880" messageEncoding="Mtom">
<readerQuotas maxStringContentLength="655360" maxArrayLength="1310720" maxNameTableCharCount="1310720" maxBytesPerRead="327680" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SocialProxyService">
<endpoint name="BasicEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpTextBinding_SocialProxy" />
<endpoint name="MtomEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpMtomBinding_SocialProxy" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Client
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_SocialProxy" messageEncoding="Mtom" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://socialproxy.local/socialproxy.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SocialProxy"
contract="Webservice.SocialProxy" name="BasicHttpBinding_SocialProxy" />
</client>
</system.serviceModel>
Problem is:
If I don't set Mtom messageEncoding # the client, everything works via plain-text. But when I set it to use Mtom, I'll get an exception:
The remote server returned an error: (415) Cannot process the message because the content type 'multipart/related; type="application/xop+xml";start="<http://tempuri.org/0>";boundary="uuid:65a6b418-8eb3-4c76-b4c0-ea3486a56892+id=2";start-info="text/xml"' was not the expected type 'text/xml; charset=utf-8'..
Anyone able to help me out? :-)
If you want to add a new endpoint (for newer clients), that endpoint needs to be in a different address. Since you didn't get any error, I imagine you have an incorrect name in the name attribute of the <service> element. Remember that the name attribute should contain the fully-qualified name of the service class. If your service class is at the namespace InfoCaster.SocialProxy, your service configuration should be defined like below:
<services>
<service name="InfoCaster.SocialProxy.SocialProxyService">
<endpoint name="BasicEndpoint_SocialProxy" address="" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpTextBinding_SocialProxy" />
<endpoint name="MtomEndpoint_SocialProxy" address="newClients" contract="InfoCaster.SocialProxy.ISocialProxy" binding="basicHttpBinding" bindingConfiguration="BasicHttpMtomBinding_SocialProxy" />
</service>
</services>
And the clients would have something like
<client>
<endpoint address="http://socialproxy.local/socialproxy.svc/newClients"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_SocialProxy"
contract="Webservice.SocialProxy" name="BasicHttpBinding_SocialProxy" />
</client>
Now, if you want a single endpoint which can support both text and MTOM in a way that clients sending text receive a text response, and clients which send MTOM receive a MTOM response back, you can still do it. You'll need a custom encoder, and I wrote one in the post at http://blogs.msdn.com/b/carlosfigueira/archive/2011/02/16/using-mtom-in-a-wcf-custom-encoder.aspx.
I've tried this on two machines and can't figure it out. I've followed the instructions here (http://msdn.microsoft.com/en-us/library/ms731053.aspx) and ensured that the TCP listener service is running. However, next to the site application, I see "Unknown (net.tcp)" as the status.
For enabled protocols in IIS, they are listed as "http,net.tcp". My binding for net.tcp is "808:*" and the app pool is .NET 4.0 integrated. Let me know what information I can provide.
Also, when trying to connect, it says it cannot connect to the mex endpoint. My service endpoint code is below. Any help is appreciated. Thanks.
<system.serviceModel>
<services>
<service name="Sandbox.ClientSideWCF.Service">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:808/service.svc" />
</baseAddresses>
</host>
<endpoint name="TcpEndpoint" address="" contract="Sandbox.ClientSideWCF.IService" binding="netTcpBinding" />
<endpoint name="MetaInfo" contract="IMetadataExchange" binding="netTcpBinding" address="mex" />
</service>
</services>
....
</system.ServiceModel>
The < baseAddresses > element is for self-hosted services. See here:
http://msdn.microsoft.com/en-us/library/ms788995.aspx
Try removing it. Also see this link How to: Host a WCF Service in WAS:
http://msdn.microsoft.com/en-us/library/ms733109.aspx
I think I figured it out. The problem was that I didn't include a service behavior. I added an empty behavior and it worked. I didn't know this was required.
Despite all of my efforts, I have not been able to get my simple WCF service hosted on IIS with SSL.
We are using windows server 2k3 with IIS 6.0 and we have up to .NET 4.0 installed on the server (web site is configured for 4.0)
If i go to http//.../rptService.svc url, I get the .svc page with the code blocks and ?wsdl url
on the other hand, if i go to https//.../rptService.svc I get a "Resource not found" 404 error. (colons on urls are removed b/c of spam prevention)
The web site has a working SSL certificate enabled for it.
My relevant web.config file is as follows:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="rptBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="wcfApp.rptServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpsGetEnabled="false" httpGetEnabled="true" />
<serviceTimeouts/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="wcfApp.rptServiceBehavior"
name="wcfApp.rptService">
<endpoint binding="wsHttpBinding" bindingConfiguration="rptBinding" contract="wcfApp.rptService"
address="">
</endpoint>
<endpoint name="MetadataBinding" address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
I have tried just about 100 different ways to write the web.config file from 150 different blog/web posts with similar situations, and have not gotten anything to work thus far.
My end goal is to get this wcf service hosted accepting a username/password token with a custom user name validator, but right now I can't even get it working with SSL!
Application is being built in VS 2010.
Please let me know if there is any more information that I can provide.
Any help is appreciated!