
The other day at a client project, we wanted to generate a proxy using svcutil as we’d done many times before.
However, the svcutil kept throwing strange error messages. Amongst them were:
- Other mime type expected, expected application/soap+msbin1 but got application/soap+xml (HTTP error 415)
- Could not import namespace <xyz>
As it turned out, the problem was the following: Everything seemed to work because going to the .svc URL and adding ?wsdl produced the desired output.
However, this wsdl does some schema imports, by referencing the svc URL, but this time using ?xsd=xsd0 , ?xsd=xsd1 etc. The strange thing was that these references produced errors (also when referenced by URL via Internet Explorer). This was also the reason that svcutil started throwing errors…
After some more investigation, the culprit became clear. In order to generated the xsd output, the WCF service executes some code generation and dynamically compiles this. (Discovered using the procesmon sysinternals tool). In order to be able to do that, the current Identity (in this case the AppPool Identity of our virtual directory) needs to have the "List Folder / Read Data" permission, which it does not normally have.
All these problems do not occur if you are running your website under the Network Service account, because account in fact does have these rights.
So in the end the trick is to add the additional right on the c:windowstemp folder for your App Pool Identity to solve the problem.
Interestingly, if you look at the default rights using IIS7 and Vista, there is a default right assigned to the IIS_IUSERS group on the c:windowstemp directory. Can you guess the additional permission ๐ ? Probably MS has run into the same problem and fixed it in Vista and hopefully also in Windows Server 2008. In this case, making your App Pool Identity a member of the IIS_IUSERS group should be sufficient.
[15-2-2008: Fixed typo]
14 comments
Thanks a lot for your post!!! I’ve tried for 4 hours to find the problem. Giving to “Everyone” ‘modify’ right on the ‘c:windowstemp’ directory solved the issue!
Matthieu
“…problem and fixed it voor Vista..” What’s a ‘voor’?! ๐
josd
Typo fixed ๐
Raimondb
Thank you.
Thank YOU.
THANK YOU.
THANK YOU!
Life was good. My WCF service was running fine. Until I needed to make a tiny addition to the service. And I could no longer update the web reference in the client.
Spent 5 hours at office to try to understand why. Went home and tried 3 hours to understand why. Googled, googled, tested, ran process explorer, nothing.
Until I hit this page.
Yep. I had changed the account of the app pool so that I could access another app from the service.
After given the rights to the temp dir, all works again.
I’ll grab a beer now, and would gladly offer you one too. Or two.
Thanks. Saved me.
Weston
Me too spent more than 10 hours for searching the solution for this problem. I tried same code on Vista IIS7 and getting different error and on IIS 6 on Win 2003 different. Given permission on temp folder and it got solved.
Thanks a lot.
Chandra P Singh
Thanks so much for this post, you just saved me from hours of frustration!
Neil
Hi,
I am preparing a [microsoft] service bus demo application using WCF application project, so that I can add this service ref. in my client using Add Service Ref. feature.
But I am not able to run the client, as it gives error,
“Transport security is required for this connection.The endpoint requires a secure channel to connect.”
Here is my Service.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
41
42
43
44
45
46
47
48
49
50
And Client.config 1
16
2
3
4
5
6
10
12
14
15
17
18
19
20
21
22
29
30
Any help will be greatly appreciated.
Thanks,
Prashant.
prashant
Was the client side config autogenerated or handtweaked? Do you have code like this in your client?
// create the credentials object for the endpoint
TransportClientEndpointBehavior userNamePasswordServiceBusCredential = new TransportClientEndpointBehavior();
userNamePasswordServiceBusCredential.CredentialType = TransportClientCredentialType.UserNamePassword;
userNamePasswordServiceBusCredential.Credentials.UserName.UserName = solutionName;
userNamePasswordServiceBusCredential.Credentials.UserName.Password = solutionPassword;
// create the channel factory loading the configuration channelFactory = (“RelayEndpoint”, new EndpointAddress(serviceUri));
ChannelFactory
new ChannelFactory
// apply the Service Bus credentials
channelFactory.Endpoint.Behaviors.Add(userNamePasswordServiceBusCredential);
The thing is that you need to explicitly authenticate in this style when going to the real servicebus. If you are not doing that, you’re likely to get the mentioned security message.
See also for a complete sample: http://blogs.msdn.com/harishpa/archive/2008/11/07/my-first-azure-solution-myazureworldsolution-and-echo-sample-in-net-services-sdk.aspx
Raimondb
Hi,
Thanks a lot for reply.
I added credentials in client code using TransportClientEndpointBehavior class.
Now stuck at the weird exception,
—
The server at sb://servicebus.windows.net/services/ppSolution/WOService/ rejected the session-establishment request.
and inner exception —
“Error while reading message framing format at position 0 of stream (state: ReadingUpgradeRecord)”
Here is stack trace —
“rnServer stack trace: rn at Microsoft.ServiceBus.Channels.ConnectionUpgradeHelper.ValidatePreambleResponse(Byte[] buffer, Int32 count, ClientFramingDecoder decoder, Uri via)rn at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)rn at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)rn at Microsoft.ServiceBus.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)rn at Microsoft.ServiceBus.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)rn at Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout)rn at Microsoft.ServiceBus.Channels.LayeredChannel`1.OnOpen(TimeSpan timeout)rn at Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout)rn at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)rn at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)rn at System.ServiceModel.Channels.CommunicationObject.Open()rnrnException rethrown at [0]: rn at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)rn at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)rn at System.ServiceModel.ICommunicationObject.Open()rn at GRSClient.Program.Main(String[] args) in C:\Program Files\Microsoft .NET Services (Dec 2008 CTP) SDK\Samples\ServiceBus\ExploringFeatures\RelayAuthentication\Username\MySample\GRSClient\Program.cs:line 39rn at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)rn at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)rn at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()rn at System.Threading.ThreadHelper.ThreadStart_Context(Object state)rn at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)rn at System.Threading.ThreadHelper.ThreadStart()”
Thanks a lot in anticipation,
Prashant.
prashant
Thank you for posting this!!! Was scratching my temple on this for a while…
Aleks Jones
THANK YOU!! I’ve spent the whole day trying to figure this out.
Phillip Scott Givens
Thanks a lot….
It helped me a lot … I was unable to resolve it for past some weeks…
Hari
YOR ARE DA MANNNNN!!!
Jassi
Thanks for the solution.
But I gone through this problem in One machine only and not coming in other machines having the same Configuration (Windows 7).
Uday