An error occurred while trying to make a request to URI:
'http://localhost:8732/Design_Time_Addresses/WCF/Service1/'. This
could be due to attempting to
access a service in a cross-domain way without a proper cross-domain
policy in place, or a
policy that is unsuitable for SOAP services. You may need to contact
the owner of the service
to publish a cross-domain policy file and to ensure it allows
SOAP-related HTTP headers to be
sent. This error may also be caused by using internal types in the web
service proxy without
using the InternalsVisibleToAttribute attribute. Please see the inner
exception for more
details.
the error appears when result returned from the wcf
I consumed this wcf via console, website, win forms and it works properly
I use 2 xml files in the WCF library :
clientaccesspolicy.xml
crossdomain.xml
It used to make my brain hurt too.
I figured out for my use I needed this file:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
named clientaccesspolicy.xml
The trick is that is has to be at the root of your web server. That being said you need to be able to browse the file. In your case located at:
http://localhost:8732/clientaccesspolicy.xml
If you cannot see the file silverlight will always complain and boy does it complain whenever it can!
I should point out that my policy file is not restrictive, so use it wisely.
Oh, that problem. Besides the crossdomain, you cannot run the debugger from VS2010 which is what i'm gather from that localhost URL. Try publishing silverlight app on the domain or server that your WCF is on. For example, if your web service is on http://10.xx.xx.xx/sites/myWCF, publish your silverlight app on http://10.xx.xx.xx/sites/MySilverlightApp. You're debugger is going to run as http://localhost:somePort which is definitely going to give you problems even with a cross-domain policy file. Apart from that, ensure that you config file for your web.service is correct. Ensure all the interfaces have endpoint bindings and there is a host on the main service location(sounds obvious, but is a common error).
Related
.NET Client while consuming the WCF service I am able to change GenerateMessageContracts settings manually here.
File: Reference.svcmap
<ReferenceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" ID="c3e3cd74-61c2-408a-a511-63a2b654abd3"
xmlns="urn:schemas-microsoft-com:xml-wcfservicemap">
<ClientOptions>
…………
<GenerateMessageContracts>true</GenerateMessageContracts>
</ClientOptions>
</ReferenceGroup>
I would like to change these setting in the WCF Service itself.
Dont know how to set GenerateMessageContracts manually for PHP client.
Anybody knows this?
You can't change that setting on the server side. The metadata exposed by the service (WSDL) which is consumed by the client side does not have any information regarding message contracts - that's a WCF term, while WSDL is a general-purpose standard. You can have two clients, one with message contracts, and one without, which send exactly the same request (and accepts the same response) to the service, and as far as the service is concerned, the requests are identical.
I have a silverlight application hosted on an asp.net web application including a WCF SOAP web service. The application is running under an HTTPS://... link using SSL. When I deploy it on our test server running IIS 7.5, everything works fine and as expected.
I also have a second web application including a RESTful WCF service which runs using SSL on both my local machine and the mentioned test server (but no silverlight client in this case).
My problem is that the silverlight client receives a Security error when getting responses from the SOAP service in the part where deserialization should take place, but only on my local machine.
return base.Channel.EndGet...(IAsyncResult) // <-- exception reported here:
System.ServiceModel.CommunicationException: An error occurred while
trying to make a request to URI 'https://localmachinename.domain.com:8000/Service.svc'.
This could be due to attempting to access a service in a cross-domain way without a
proper cross-domain policy in place, or a policy that is unsuitable for SOAP services.
You may need to contact the owner of the service to publish a cross-domain policy file
and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be
caused by using internal types in the web service proxy without using the
InternalsVisibleToAttribute attribute. Please see the inner exception for more
details. ---> System.Security.SecurityException --->
System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClassa.b__9(Object sendState)
at System.Net.Browser.AsyncHelper.c__DisplayClass4.b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.Remoting.RealProxy.Invoke(Object[] args)
at proxy_2.EndGetTypes(IAsyncResult )
at NameSpace.ClientClass.ServiceContractInterfaceImplementation.EndGetTypes(IAsyncResult result)
My clientaccesspolicy.xml for the SOAP service looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="SOAPAction">
<domain uri="*" />
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Any hints what I'm doing wrong?
The deployed application runs fine on our test web server.
Dec 06 2012: The problem still persists. Some updates / more information:
The web service uses windows authentication and impersonation. The only difference between test server and local machine is that the application pools run under different identities which in both cases is a technical domain user. The only difference I've found is that the user on my local machine was not granted the "Trusted for delegation" flag in Active Directory. So I assumed it could be a Kerberos problem. However, when I run my restful WCF service and client, this never was a problem. Besides, using a windows forms client for the SOAP service, everything runs fine on my local machine and developing/debugging is just possible as intended.
So it has to be a Silverlight problem.
What I do not get is, assuming this dreaded security error results from a crossdomain policy problem as it does in most cases, where are those domains crossed? Everything should be happining on the local machine, no other services are called. This shouldn't happen using IIS Express, should it?
Anybody able to help?
The clientaccesspolicy.xml should be placed in wwroot folder and also include crossdomain.xml
If you have multiple startup project in solution make sure you are running your Service and proper Silverlight project. I had two silverlight projects and was starting the wrong one that didnt contain clientaccesspolicy.xml.
This might be a really stupid question, but I've been unable to figure out a solution.
I have a WCF service hosted on a site that uses SiteMinder authentication. The authentication relies on a cookie in the client request.The problem is that when I try to generate a proxy class using svcutil, the operation fails because when svcutill tries to get the metadata, it obviously doesn't add the SiteMinder cookie to its request.I was therefore wondering if there was a simple way to generate the WCF service proxy class programatically.
If you have access to the compiled service DLL file, you can use the SvcUtil command line utility to generate the WSDL and associated XSDs for the data contracts. The main wrinkle with this approach is you'll need to add the name of the XSD file generated by SvcUtil in each xsd:import element in the schemaLocation attribute value.
Below are samples of modified xsd:import elements. For the "http://tempuri.org/" namespace, I added the schemaLocation attribute with the value of "tempuri.org.xsd" to let the Add Service Reference process know to look for that file in the same folder as the WSDL file. If your WSDL uses wsdl:import instead, add a location attribute instead of a schemaLocation attribute. This related question and answer should give a good start.
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import namespace="http://tempuri.org/" schemaLocation="tempuri.org.xsd" />
<xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" schemaLocation="schemas.microsoft.com.2003.10.Serialization.xsd" />
</xsd:schema>
</wsdl:types>
EDIT:
Generating the client code using the compiled service DLL requires a two step process. SvcUtil needs the service WSDL to generate the client. It cannot directly use the compiled DLL.
First generate the WSDL using the DLL that contains the ServiceContract. I think you can use the service implementation file if the service contract DLL is also in the same folder.
cd "\Path\To\Your\Service\DLLs"
svcutil YourService.DLL
This will create several files depending on your service structure. There'll be one .WSDL file and several .XSD files. Edit these files as shown above.
Lastly, either use the Visual Studio Add Service Reference dialog to select the edited .WSDL file (just enter the full path and file name) to generate the client code or use SvcUtil as follows:
svcutil *.wsdl *.xsd /language:C#
I've added a WCF Service Library to a Silverlight project. But when I try calling a method on the service I get a CommunicationException complaining about accessing a service in a cross-domain way.
I've tried adding both a crossdomain.xml and clientaccesspolicy.xml to the service library project, but it doesn't help.
Any idea what I'm doing wrong?
You mention that the policy files are going into the service library, have you checked they get placed into the correct place within the website?
Try running up fiddler to see what the web site is actually returning when the service is called.
Copy CrossDomain.xml and clientpolicy.xml files in C:\Inetpub\wwwroot path. :)
I have a wcf web service and I need to provide the client with the wsdl files.
Previously I used svcutil on the .dll and everything was fine.
However, recently I implemented the factory to Flaten the wsdl file (re: http://wcfextras.codeplex.com/).
My questions is this: Is there anyway of either using svcutil on the .svc to extract the Flattened .WSDL files or maybe somehow hit up the web service when it is running in the local webdev server to retrieve the .WSDL files?
As far as I'm aware, if I was to navigate to my local web dev server (http://localhost:2916/Service.svc?wsdl) and if i was to view source and saved that as .wsdl that this is wrong and would not provide all the relevant information.
note: See below for how the Factory is used in the .svc file....
<% #ServiceHost Factory="CompanyName.ServiceModel.Extensions.Description.FlatWsdlServiceHostFactory" language=c# Service="CompanyName.WebServices.Service"%>
Thanks,
Steven
Yes, you should still be able to use svcutil to extract the WSDL from your service, even if you have an extension installed that will flatten the WSDL.
To download the metadata document(s) from your running service, use this command:
svcutil /t:metadata http://service/metadataEndpoint
You need to point your URL to the metadata endpoint defined in your config, e.g. the endpoint that's defined to use "mexHttpBinding" or "mexTcpBinding" and the "IMetadataExchange" contract.
If you don't have any metadata exchange endpoints defined, you won't be able to retrieve that information, obviously.