HTTP 400 Bad Request Error Attempting to Add Web Link to WCF Service

I am trying to migrate a legacy WSE 3 web service to WCF. Since maintaining backward compatibility with WSE 3 clients is the goal, I followed the recommendations in this article .

After much trial and error, I can call the WCF service on my WSE 3 client. However, I cannot add or update a web link to this service from Visual Studio 2005 (with WSE 3 installed). Answer: “Request error with HTTP status 400:“ Bad request. ”I get the same error trying to generate a proxy server using the wsewsdl3 utility. I can add a link to the service using VS 2008.

I tried using the service in IIS 7.5 on both Windows 7 and Windows Server 2008 R2 with the same result. Any solutions or troubleshooting tips?

Here are the relevant sections from the configuration file for my WCF service.

<system.serviceModel> <services> <service behaviorConfiguration="MyBehavior" name="MyService"> <endpoint address="" binding="customBinding" bindingConfiguration="wseBinding" contract="IMyService" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> </service> </services> <bindings> <customBinding> <binding name="wseBinding"> <security authenticationMode="UserNameOverTransport" /> <mtomMessageEncoding messageVersion="Soap11WSAddressingAugust2004" /> <httpsTransport/> </binding> </customBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="MyBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MyCustomValidator" /> </serviceCredentials> <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="MyRoleProvider" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> </system.serviceModel> 

UPDATE:. After trying to poll Paul tracing, I decided that the exception was System.Xml.XmlException: the message body could not be read because it is empty

Unfortunately, this does not seem to help much. Another thing I noticed is the presence of a separate httpsGetEnabled attribute of the serviceMetadata element. I added this and set it to true, since it is an https service, but the result was the same. For some reason, WCF seems to not recognize that it is a metadata request.

+7
source share
2 answers

You can try enabling WCF tracing on the server. Insert this before line </system.serviceModel> :

 <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" maxMessagesToLog ="3000" /> </diagnostics> 

Insert this after the line </system.serviceModel> :

 <system.diagnostics> <sharedListeners> <add name="sharedListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\logs\tracelog.svclog" /> </sharedListeners> <sources> <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing" > <listeners> <add name="sharedListener" /> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Verbose"> <listeners> <add name="sharedListener" /> </listeners> </source> <source name="ApplicationLogging" switchValue="Information" > <listeners> <add name="sharedListener" /> </listeners> </source> </sources> </system.diagnostics> 

After duplicating the error, run the WCF trace tool and open the log file. There is probably some exception.

- EDIT -

Well, this is an interesting error message. This leads to more Google results:

+2
source

I would do the following:

 <serviceMetadata httpGetEnabled="true" /> 

change to:

 <serviceMetadata httpsGetEnabled="true" /> 

Besides. Have you set the HTTPS binding properties: http://blogs.msdn.com/b/wenlong/archive/2007/08/02/how-to-change-hostname-in-wsdl-of-an-iis-hosted-service .aspx

0
source

All Articles