none
System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request RRS feed

  • Question

  • Hi,

    I am calling a service from BizTalk. Send Port - WCF-Custom, Basic-HttpBinding.

    I created the send port with the binding file that was created when I generated the schema from the service. This is a service written in Java.

    I get the error: '      Details:"System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.'

    I see nothing in Fiddler. I have increased the maxmessage and buffer size.

    I get a response when I call this service from a c#.net application.

    Any help is appreciated.

    Regards,

    Sharmishtha

    Wednesday, December 10, 2014 5:58 AM

Answers

All replies

  • I think you are dealing with Large message response from the web service .In this case you need to modify the config file for both client (BizTalk WCF service ) and at the server end  which is your java web service . Something like below

    <bindings><wsHttpBinding>    <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"    maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000"    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"    allowCookies="false">        <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000"        maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />        <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />        <security mode="Message">            <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />            <message clientCredentialType="Windows" negotiateServiceCredential="true"            algorithmSuite="Default" establishSecurityContext="true" />        </security>    </binding></wsHttpBinding></bindings><services>    <service name="MyService" behaviorConfiguration="MyServiceTypeBehaviors">        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" contract="MyIService"/>        <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>     </service></services>

    Thanks

    Abhishek

    Wednesday, December 10, 2014 6:26 AM
  • If you are dealing with large messages, be sure to increase the message size and quota parameters in the config file as documented herehttp://xprog.blogspot.com/2007/12/wcf-remote-server-returned-unexpected.html
    Wednesday, December 10, 2014 6:29 AM
    Moderator
  • No, I am not dealing with large message.

    Regards,

    Sharmishtha

    Wednesday, December 10, 2014 6:30 AM
  • No, I am not dealing with large message.

    Regards,

    Sharmishtha

    Have you tried hitting the service from SOAP UI or any console Application ? Is it responding to the request .

    Thanks
    Abhishek

    Wednesday, December 10, 2014 6:36 AM
  • Hi, 

    are you saying that Fiddler cannot even log the request being sent?  if you can, compare the requests. Are you able to logon to the remote system? What does the remote side log as an error?

    If I had the same situation I would start to look at security. If you can run the web service from c# you are probably using your own account - and hence a user proxy. Perhaps BizTalk server is configured to use a different proxy.  I wouldn't set a high probability for this as I would have expected a security error.


    mark

    Wednesday, December 10, 2014 6:56 AM
  • Thanks for the responses.

    The issue is with the content type . text\xml is not correct, it needs to be blank.

    Posted another thread in the forum, to see how to set the content type.

    Regards,

    Sharmishtha

    Wednesday, December 10, 2014 9:50 AM
  • You issue is not with Content Type text\xml  On the wire web request is passed as text\xml as content type and  issues is neither with send port folder .

    I would say you need to check your send port binding and  SOAP Action header inside your Send Handler . Best way to import the binding generated while consuming service through BizTalk WCF Service Consuming Wizard.

    I suspect you are sending wrong message to web service and thus due to data contract conflict you are getting exception from the service .

    There are various articles which can guide you how to consume web service in BizTalk .Some of them are listed below .

    How to Use the BizTalk WCF Service Consuming Wizard to Consume a WCF Service

    BizTalk and WCF: Part I, Operation Patterns

    Consuming WCF Service in BizTalk 2010 Orchestration

    Thanks

    Abhishek

    • Proposed as answer by Angie Xu Tuesday, December 16, 2014 8:18 AM
    • Marked as answer by Angie Xu Wednesday, December 17, 2014 1:44 AM
    Wednesday, December 10, 2014 4:47 PM
  • Hi,

    I've already got this issue and I've posted the solution on my blog : http://stevemelan.wordpress.com/2013/05/16/http-400-bad-request-using-kerberos/

    Hope this helps you :-)

    Best Regards,


    Steve Melan - BCEE My Blog : http://stevemelan.wordpress.com

    Friday, December 12, 2014 8:19 PM