0

我正在尝试从我的 Web 应用程序发送 SMS。我正在使用第 3 方 Web 服务来推送消息。在开发环境中,我可以发送 SMS,当生产中托管的同一应用程序收到以下错误时:

System.Net.WebException: The remote server returned an error: (400) Bad Request.
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
   --- End of inner exception stack trace 
Server stack trace: 
   at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
   at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

以下是我在 web.config 中所做的更改:

     <system.net>
        <defaultProxy useDefaultCredentials="true" />
      </system.net>
<basicHttpBinding>
    <binding name="IBulkSMS" closeTimeout="00:10:00" openTimeout="00:10:00"
     receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
     maxBufferSize="500000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000"
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
     useDefaultWebProxy="true">
     <readerQuotas maxDepth="32" maxStringContentLength="10500" maxArrayLength="16384"
      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        <security mode="Transport">
      <transport clientCredentialType="None" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="UserName" algorithmSuite="Default" />
     </security>
    </binding>
</basicHttpBinding>

<endpoint address="SMS.asmx"
    binding="basicHttpBinding" bindingConfiguration="IBulkSMS"
    contract="IBulkSMS.IBulkSMS" name="IBulkSMS" >
     <identity>
     <servicePrincipalName value="host/MachineName" />
    </identity>
    </endpoint>
4

2 回答 2

2

最后我得到了解决问题的解决方案。

代理设置在生产服务器中被禁用。

如果代理被禁用,则设置 useDefaultWebProxy="false"。如果启用了代理,请设置 useDefaultWebProxy="true"。

我对绑定进行了以下更改。

<binding name="IBulkSMS" closeTimeout="00:10:00" openTimeout="00:10:00"
     receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false"
     bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
     maxBufferSize="4194304" maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
     messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
     useDefaultWebProxy="false">

它工作正常。

于 2013-09-27T05:12:04.310 回答
-1

useDefaultWebProxy="false" 在客户端应用程序中设置

于 2014-07-30T05:39:04.147 回答