There is a WCF service that I was using and now it is pointing to a new URL. Is there anyway to go and change the URL without having to delete the service from the project and add it again using the new URL.
The problem with deleting the service is stupid TFS is giving problems. Any suggestions how I can update the service url without deleting the service?
In general the url a client is pointing to is defined in the app/web.config using the endpoint element. So all you have to do is modify the address attribute to point to the new url:
<endpoint address="http://newUrl"
binding="..."
contract="..." />
Related
When attempting to add a service reference to a WCF service to my .NET project I am getting an error:
Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata.
After doing some research I decided to add a metadate exchange endpoint to my service:
<endpoint
address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"/>
Now, after adding the enedpoint I am getting a different type of error:
Could not find a base address that matches scheme http for the endpoint with binding BasicHttpBinding. Registered base address schemes are [https].
What am I doing wrong here?
If I open service in the browser, it works just fine:
https://alias.domain.com/ProjectName/MyService.svc?wsdl
mexHttpBinding is only for http:// but as your service is exposed over https:// you need to change it to mexHttpsBinding.
See here: https://msdn.microsoft.com/en-us/library/aa395212(v=vs.110).aspx
Solved!
The issue was that some XSD references in WSDL, schemaLocation in particular. For some reason schemaLocation used machine name instead of the domain name. After I fixed that I was able to add a reference to the service
I am trying to work out how to host a wcf service in sharepoint 2010 which uses castle windsor. I can host my own standard custom web service without any issues by using one of the service factories from http://msdn.microsoft.com/en-us/library/ff521586(v=office.14).aspx.
Setting up a normal wcf service with castle windsor involves modifying the global.asax but, as this is not recommended for SharePoint, I have created an HttpModule which sets up the container and I have updated the web config to use it by creating a feature reciever.
My problem is where to go next. I am using the MultipleBaseAddressBasicHttpBindingServiceHostFactory for my service because that dynamically configures all of the endpoints for the service based on the IIS configuration but in order to use castle windsor it looks like it is necessary to change to using the supplied Castle.Facilities.WcfIntegration.WindsorServiceHostFactory. I have tried just switching over to see what happens but that does not seem to work. I get the following error
Error: Cannot obtain Metadata from <svc url> If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: <svcurl> Metadata contains a reference that cannot be resolved: '<svcurl>'. The requested service, '<svcurl>' could not be activated. See the server's diagnostic trace logs for more information.HTTP GET Error URI: <svcurl> There was an error downloading '<svcurl>'. The request failed with HTTP status 404: Not Found.
I assume this is because I haven't configured an endpoint for the service but the few examples I have seen online do not seem to either.
Has anyone managed to get castle windsor and sharepoint wcf working - preferably with dynamic configuration if possible?
The error message that you are getting is that the metadata of the service is not published. To do this you need 2 things:
A mex endpoint for your service:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
And service meta data turned on in service behavior:
<serviceMetadata httpGetEnabled="True" />
being new to wcf i often stuck to write endpoint address in config file. sometime i just could not understand what address i should write in endpoint at host end where service will be running. here is one sample endpoint entry....please have a look.
<endpoint address="net.tcp://localhost/ServiceModelSamples/Service1.svc"
binding="netTcpBinding"
contract="ServiceReference1.IService1">
</endpoint>
<endpoint address="net.tcp://localhost/ServiceModelSamples/service"
binding="netTcpBinding"
contract="ServiceReference1.IService1" />
i have couple of question on endpoint address
1) when i should write endpoint address like this way
net.tcp://localhost/ServiceModelSamples/Service1.svc
i guess when we will host our service in IIS then we need to write endpoint address like above one where we need to write our svc file name.
am i right?
2) just see the below address
address="net.tcp://localhost/ServiceModelSamples/Service1.svc"
what is ServiceModelSamples do i need to mention it?
3) suppose i develop wcf service with wcf service application template and host that service in win form apps then how our endpoint address would look like below one
address="net.tcp://localhost/ServiceModelSamples/service"
do i need to write ServiceModelSamples our project name folder or we can remove it from
address like address="net.tcp://localhost/service"
it is very important for me to know that do i need to write our project folder name like
ServiceModelSamples
4) when we host wcf service in win form apps then do i need to specify our svc file name with extension.
5) specifically guide me what address i need to write when we host our service in win form apps.
my all above question may sounds very stupid but i have really confusion about address in
endpoint. i have no there way to put question here. So please have a look at my 5 points and guide me. thanks
I think your confusion comes from the differences between IIS Hosting and custom hosting.
When you use IIS to host the service, the service behaves this way:
A base address is assigned to the service automatically depending on where the service is hosted in IIS. It uses the same address mapping that a web site uses.
The service layer needs to have .svc files to expose service instances through IIS. Those service files are just mapping files that help exposing on IIS.
So to fill the address to a service hosted in IIS from the client you need to:
Find out the address that has been assigned by IIS.
Complete that address with the Service.svc file name that you want to point to.
However when using custom hosting (through ServiceHost) the service address is totally goberned by the service configuration file:
The service can configure a base address to all its endpoint via the baseAddresses setting
All endpoints can have a full address or relative address. If relative address is used then the resulting endpoint address will be the baseAddress + endpoints relative address.
When custom hosting you have complete control over the service addresses, so you don't have any of the constraints that you must follow on IIS.
I have a WCF web service hosted in IIS7 which is reporting its endpoint URL as the following in its WSDL
http://machinename/virtualdirectory/service.svc
However the actual public URL which clients need to use is actually
http://machinename.mydomain.com/virtualdirectory/service.svc
And so at the moment clients that attempt to use this web service fail unless they manually edit the endpoint URL.
I know that I can fix this by changing the bindings of the site in IIS as per HOWTO: Fix WCF Host Name on IIS however in this case the site is shared with another application which stops working if I do this and so this isn't an option.
Is there another way that I can change the endpoint URL that WCF uses for this one virtual directory?
Although not directly answering my question (how can I set the WSDL endpoint URL in the web.config file) adding the <useRequestHeadersForMetadataAddress /> element to the <serviceBehaviors> section of my web.config file did fix my problems as now the endpoint URL is based on the URL used to access the WSDL, which is always the same as the URL used to call the web service.
Note that in this SO question it indicated that I needed to supply port numbers, note that this wasn't necessary for me - just adding the <useRequestHeadersForMetadataAddress /> element was enough
<serviceBehaviors>
<behavior name="<name>">
<!-- Other options would go here -->
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
There are a couple of options depending on which version of WCF your service is using. If you're using .NET 4 or higher, look at the accepted answer to this SO question. Otherwise you can either apply the hotfix that question references or if you're really desperate, hack the metadata URL of the httpGetUrl attribut to point to a copy of the WSDL which has been manually edited to contain the desired endpoint URL.
I have started the WCF security token service template in Visual Studio. I get all things up and running over http. So now I have an STS, a WCF Service and I can call GetData(int) with the WCFTestClient. This is running on http.
Now I want to run the STS on https. So I've added it to IIS and added an https endpoint. If I browse to the sts it works on https now.
Next I create a WCF Service, add an sts reference etc. I add this WCF Service to IIS too, on https.
And the last step I create a console app, but then when I call the WCF service Cardspace is started and I get an error. First problem: I don't want Cardspace to start, and it shouldn't start as far as I know. Second: the error message is 'incoming policy failed validation'.
What are the steps to run the STS on https? Is there a tutorial?
Does anyone else finds this a familiar situation, and knows a solution?
I had the problem of cardspace starting myself and after checking the wif configuration several times I found some error in the config. After fixing the config error, everything worked.
Sorry that I could be more spesific one the error (too long ago). But be very, very sure that you have configured your sts and wcf correctly.
Did you try specifying the following: in your config under message.
<issuer address="stsurl" binding="ws2007HttpBinding"
bindingConfiguration="stsbindingconfig">
<identity>
<userPrincipalName value="fqnofUpn" />
</identity>
</issuer>