我遇到了一个问题:
从ssrs向wcf发送soap查询时,我得到了:
The remote server returned an error: (405) Method Not Allowed.
he HTTP verb POST used to access path '/Service1' is not allowed.
从ssrs发送肥皂消息到wcf工作得很完美,但突然间它破了。我没有改变下面的code.code中的任何内容。
肥皂查询非常简单:
<Query> <Method Name="GetData" Namespace="http://tempuri.org/" /> <SoapAction>http://tempuri.org/IService1/GetData</SoapAction> <ElementPath IgnoreNamespaces="true">*</ElementPath> </Query>
合同:
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
// TODO: Add your service operations here
}
implementation:
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
的web.config:
<?xml version="1.0"?> <configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
表示web.config:
这是新的web.config,当你创建wcfapplication时,它不需要你包含所有东西,它会在内部生成一个web.config,你可以在wcf测试客户端看到它:
<?xml version="1.0" encoding="utf-8"?> <configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58539/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel> </configuration>