.Net WCF SVC Info Page and Fully Qualified Server Names - c#

I have two servers on which the identical .net 2.0 WCF service code has been deployed. On both servers the code is running in a dedicated web application with a dedicated application pool assigned to it. Both the web applications and the application pools are configured, as near as I can tell from IIS, identically on both machines. Furthermore, both machines have the same exact versions of the .net framework installed.
On one server the SVC info page served up by IIS lists a fully qualified machine name but the other lists a non-fully qualified machine name. I've provided sample URLS to the info page and the results below:
://server1:1995/Service.svc yields:
You have created a service. To test this service, you will need to
create a client and use it to call the service. You can do this using
the svcutil.exe tool from the command line with the following syntax:
svcutil.exe ://server1.domain.com:1995/Service.svc?wsdl
://server2:1995/Service.svc yields:
You have created a service. To test this service, you will need to
create a client and use it to call the service. You can do this using
the svcutil.exe tool from the command line with the following syntax:
svcutil.exe ://server2:1995/Service.svc?wsdl
I wouldn't normally care about this except for the fact that a packaged product I'm using appears to insist that the URL I give it for the WSDL match exactly what the info page states and I can't figure out why it needs to be different for these two (seemingly identical) machines.
Any help would be greatly appreciated!
(please note I had to delete "http" from the hyperlinks above to keep StackOverflow happy)

The solution here was to add the following line to the SVC web.config file. The behavior was inconsistent across different versions of IIS (and possibly the .net CLR) but adding this line normalized the behavior:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

Related

Host Multiple Wcf Services On Local IIS 6

I have tried to google a lot to find a solution to how to host multiple WCF web services on local IIS 6.
So i am asking here. If I can get a step of procedure then i would be glad.
To accomplish your goal this is how to do it:
Create your new solution or just reuse current solution you have.
Create new Project under Visual C# and select WCF Service Application. For sample purposes we name it MultipleHostService project.
It will produce three files named IService1.cs, Service1.svc and Web.config
Under your MultipleHostService project add another New item, under Visual C# Select WCF Service and leave name as is.
It will product addition two files named Iservice2.cs and Service2.svc
Open your Web.Config add Behaviors and Binding configuration highlighted with red box.
If you notice we added Services node and service under it? That is the part that allows us to specify multiple services.
Now click MultipleHostService project
Click Properties
Click Web Tab
In the Servers panel
Select Local IIS in the dropdown list
And under Project URL type this : http://localhost/MultipleHostService "You can change it later on if you want"
And click Create Virtual Directory.
Build the Project MultipleHostService ( Make it sure no failed shown in Error List )
Go to browser and type the follow:
http://localhost/MultipleHostService/Service1.svc
http://localhost/MultipleHostService/Service2.svc
You should see something in the browser like this:
Tools and settings I've used:
Visual Studio 2013
IIS 7
.Net Framework 4.5
Improvements :
You can refactor proper naming for your services.
Remove unnecessary XML node in the configuration file like unused behavior.
Disclaimer : I haven't tested it using IIS 6 but I'm confident that it works on IIS7. Configuration about IIS is not part of this topic so you migt run
some issues which I'm not aware of. There are also some other ways to accomplish multiple hosting of services but this topic is focusing on usage of configuration file. And please do some study on proper Bindings, Behavior and MetaDataExhange which I didn't discuss here.

What is the best way to move FedEx .net webservices from developer environment to production?

FedEx doesn't provide UDDI services but need to be downloaded as a WSDL file. Once the developement is complete, the development WSDL need to be replaced with production WSDL. I am using Visual Studio 2008 and just replacing the WSDL doesn't automatically work in production, but need to be reimported and rebuild the project. This creates two different binary signatures for both devlopment and production environments. I need to accomplish this through some configuration files so my binaries will be same for my development and production environments. Any ideas??? Thanks!
The only change in WSDL filess is location value.
<port name="RateServicePort" binding="ns:RateServiceSoapBinding">
<s1:address location="https://ws.fedex.com:443/web-services" />
</port>
We normally override the URL, similar to how Dave Zych said, along these lines:
prod = new Service.Service();
// ... read configuration into cfg ...
prod.Url = cfg.ServiceURL;
The URL changes depending on the environment via the configuration. The WSDL is consistent, as are the underlying classes.

Consuming a WCF Service that is hosted in a Windows Service from outside solution

I've set up a WCF Library hosted in a Windows Service using the following walk-through:
http://msdn.microsoft.com/en-us/library/ff649818.aspx
The consumer winforms is in the same solution, which is located locally on my work PC's C: drive.
The walk-through works i.e. the winforms button gives me the correct answer.
If I create a new Solution on the C-Drive with a single Windows Forms project in it I cannot successfully add a service reference to this running service, i get the following message:
The detailed message says the following:
The URI prefix is not recognized. Metadata contains a reference that
cannot be resolved: 'net.tcp://localhost:8526/Service1'. Could not
connect to net.tcp://localhost:8526/Service1. The connection attempt
lasted for a time span of 00:00:02.0020000. TCP error code 10061: No
connection could be made because the target machine actively refused
it 127.0.0.1:8526. No connection could be made because the target
machine actively refused it 127.0.0.1:8526 If the service is defined
in the current solution, try building the solution and adding the
service reference again.
Why can I add this Service Reference ok to a project within the same Solution as the Service but not from a project in a different solution?
EDIT
My colleague found an error in the MSDN article - I have detailed his find HERE
The step by step walkthrough article at MSDN ends unfortunately where it gets interesting, so let's continue here. Because there are many possibilities which may cause the error, I've described several options (= scencarios which may cause the issue) below, which should help troubleshooting:
1st option: Try to specify
net.tcp://localhost:8526/Service1/mex
when you add the service reference to your new client - ensure that the service is installed and running before you do that.
Explanation: The suffix "mex" stands for "metadata exchange" and allows Visual Studio to download details of the WCF contract. This suffix is also used in the walk-through example, it was added automatically (you will see it in the Address field if re-open the added service reference by right-clicking on "Configure Service-Reference...").
2nd option: What I noticed when I tested the walk-through is that it helps sometimes to right-click on the service reference and select in the contect menu "Update Service-Reference".
After a while in the systray you can see the balloon message "Your service(s) have been hosted.", after which you can start the client within the same solution. In this case, the service has been temporarily created but is not deployed permanently - which means, if you stop debugging, it is removed. As a result, you can't use this service from a remote PC, it is just visible within the solution in Visual Studio. Visual Studio internally invokes the tool
WcfSvcHost.Exe /Service:<Service1Binary> /Configuration:<Service1Config>
supporting it with the right parameters to register the service properly (you can find this tool in Visual Studio's Common7\IDE subdirectory, and there is also WcfTestClient.Exe available - a tool which acts as a client, very useful to debug WCF).
For instance, if you have stopped debugging, and launch the client.exe from Windows Explorer outside of Visual Studio, then it does not find the service and you're getting exactly the error message you have described in your question.
There are two interesting links regarding this matter at Microsoft:
Problem with Metadata Exchange and Publishing Metadata
Note that this is different from deploying it as described in the 3rd option.
3rd option: Have you used InstallUtil to deploy the service? In this case it can happen that you have accidently removed the [...]/bin/Debug subdirectory and the service fails to start, because the .EXE file is missing.
Note: This can be avoided if you're using a ServiceInstaller project, which copies the binaries before the service is registered. Or - if you want to use InstallUtil for simplicity - you can copy the service binaries to a target directory (including the .config files and .dlls) before you register it.
4th option: If you run the service on a remote computer, you need to specify the proper host name or IP address of the host instead of localhost, and you need to ensure that the personal firewall (windows firewall or 3rd party) doesn't block the port 8526 (the port number which was used in the example). Specify an exception to allow this port for incoming and outgoing traffic.
5th and final option (UPDATE): Naming conflict - Service1 is the service but also the class name in the Wcf library. Either fully qualify the class name you're using from the WCF library in the service, i.e. WcfServiceLibrary1.Service1 or rename the class. Whytheq has found it himself with a colleague and as posted it here.
More reading: Check out this article, which I've found recently: "WCF: a few tips". It explains very well troubleshooting WCF. The only change I would made to the console hosting example is to replace the using statement by a
ServiceHost host = new ServiceHost(typeof(Service));
try
{
host.Open();
Console.WriteLine("WCF Service is ready for requests." +
"Press any key to close the service.");
Console.WriteLine();
Console.Read();
Console.WriteLine("Closing service...");
}
finally
{
if (host!=null) {
host.Close();
host=null;
}
}
If you want to know more about the reason why, check out this article: "Proxy open and close".
You can get round this as follows:
Browse the service's WSDL URL and save the WSDL to a local file.
Then make the following changes to the file:
Remove the namespace prefix from the name used for the wsdl:binding i.e. change
name="wb:wsclocks-inboundSoapBinding" to be
name="wsclocks-inboundSoapBinding"
Change the binding attribute of the wsdl:port attribute to match, and also remove the namespace prefix from the value of the name attribute, so it is just wsclocks-inbound.
Then run svcutil /o:Client\WBServices /noConfig

Web service takes long time to run the first time

I am new to writing and deploying web services and I have a web service that when I run it from my C# applications, it will take 4-8 seconds to respond the first call. Subsequent calls are in the half second range. If I call the web service from internet explorer, it returns immediately.
My Web service is a Soap web service running on windows web server 2008 server. I have been looking for a solution for several days and nothing I have tried has helped. The 2 things have tried that don't appear to work is precompile the XmlSerializers (Generate serialization assembly is on) and precompile the web service using aspnet_compiler. The output of aspnet_compiler I copy to the server and paste into the appropriate folder.
My application is calling the web services by using the auto generated code web reference code created when you use the Add Web Reference wizard.
Is there something else I can try?
A common culprit is checking of Publisher Evidence (basically, assembly signatures) in the absense of open connectivity to the internet.
Try adding the following line to your ASPNET.CONFIG or APP.CONFIG file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
See for background and details online articles, e.g.
http://blogs.msdn.com/b/pfedev/archive/2008/11/26/best-practice-generatepublisherevidence-in-aspnet-config.aspx

SilverLight Service Deployment

I've written a silverlight app with a simple wcf service. Runs great on my computer, when I publish it to my web account it no longer works with the service. I tried editing the clintconfig file to set the endpoint to the new location, that did not fix it. So I downloaded this simple SilverLight App with WCF example setup for deploying, and it also works on my personal machine, but not when I publish it to my domain. My account supports asp.net, wcf, etc.. The link to the example I downloaded: http://www.codeproject.com/Articles/152778/Deploying-Silverlight-with-WCF-Services
I'm new to this, so I'm wondering if this is something that should work without additional work, or if I'm missing something. I'm not getting any errors, I'm just not getting the message displayed on the screen from the service.
Added following after Hatchets Comment:
I'm trying to figure out how to find a error message. So far the only way I know it's not working is I don't see the message that is returned from the service. SilverLight displays the returned message, "Hello from My WCF Service". I see it on my machine, but not when I publish it to my domain. The app I downloaded, if I understand it right, is setup to work without having to change the endpoint address, but i'm so new to this, I've not figured out what i'm missing yet.
Thanks.
Added after comments below:
I grabed fiddler, and after i added the tag, i was able to see an error in fiddler, and when browsing to the .svc file. Error:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'multipleSiteBindingsEnabled'. Note that attribute names are case-sensitive.
Source Error:
Line 30: </bindings>
Line 31: <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
Line 32: multipleSiteBindingsEnabled="true" />
Line 33: <services>
Line 34: <service name="testWCF.Web.Service1">
Source File: \boswinfs03\home\users\web\b706\whl.forystpcom\web.config Line: 32
Version Information: Microsoft .NET Framework Version:2.0.50727.4211; ASP.NET Version:2.0.50727.4016
I'm unfamiliar with multipleSiteBindingsEnabled and the best way to handle this, does the version of .NET running affect this? The server i'm running this on supports up to 3.5 it says, but I notice it quotes version 2.0 in the error, not sure if they are connected.
I know the example you're following is not RIA Services, and this link is, but it may be helpful as it goes over some common Silverlight/WCF services deployment problems
http://blogs.msdn.com/b/saurabh/archive/2010/03/16/ria-services-application-deployment.aspx
MultipleSitesBindingEnabled is part of the 4.0 update, so it can not run on a server that supports up to 3.5. You need to configure your service to use a specific endpoint(s).
Sourse: MSDN
P.S. When browsing to the .svc, it will say that .net 2.0 is installed for anything from 2.0 - 3.5 , but then 4.0 is installed it will say 4.0.
I'm not considering this the answer, just thought it was a cleaner place to put an update. My first problem was my program was using 4.0 and my provider did not support 4.0. My 2nd problem was: This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.Parameter name: item" , I found a fix for this at: http://www.j2i.net/blogengine/post/2010/02/08/This-collection-already-contains-an-address-with-scheme-http-There-can-be-at-most-one-address-per-scheme-in-this-collectionParameter-name-item.aspx
I was able to fix this by adding the following code.
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://www.mydomain.com" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Thanks to all the Help everyone. Thanks for carlosfigueira for the suggestion to download the fiddler app. If you want to repost that suggestion to a answer I'll check it, as it helped me figure out the errors I was getting, leading to solving the problem.

Categories

Resources