0
WCF 웹 서비스를 만드는 데 초보자입니다. 대상 프레임 워크 4.5 VS2012 사용하고 있습니다. 내 프로젝트에 WCF 서비스 파일을 추가했습니다. 에서 "IService.cs는"나는 다음과 같은 코드 WCF 서비스에 메서드가 없습니다.
namespace _3TWebServ
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "Calculate")]
String Calculate(Inputs ip1);
}
[DataContract]
public class Inputs
{
[DataMember(Name = "Coil_type")]
public string Coil_type { get; set;}
[DataMember(Name = "Finned_length")]
public string Finned_length { get; set;}
}
}
와 "Service.svc.cs"
namespace _3TWebServ
{
public class Service1 : IService1
{
[DataMember]
public string input;
public String Calculate(Inputs ip1)
{
String str = ip1.Coil_type + ip1.Finned_length;
return str;
}
}
}
그러나 나는 그것이 표시되지 내 서비스를 실행할 때 문제가 온다에서
을 쓴 내 메서드 Calulate, 다음과 같이 URL을 전달할 때 localhost : 2121/Service1.svc/"method not allowed"오류가 표시됩니다.Google 검색을 수행하고 IIS 관리자 디렉터리 검색을 활성화했습니다. 구성 파일은 다음과 같습니다.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="_3TWebServ.IService1" name="_3TWebServ.Service1">
<endpoint address="" behaviorConfiguration="Rest" binding="webHttpBinding" contract="_3TWebServ.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!--endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="_3TWebServ.IService1">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Rest">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
HTTP 게시 요청 방법을 알려주십시오. – Rahul
클라이언트 응용 프로그램에 따라 다릅니다. HttpClient, HttpWebRequest, ajax/javasript, fiddler를 사용하여 POST 요청을 할 수 있습니다. 인터넷에서 자세한 내용을 검색 할 수 있습니다. – Praburaj