사용자 지정 끝점으로 WCF 웹 서비스가 있습니다. 클라이언트 응용 프로그램에서이 웹 서비스 (IIS에서 호스팅 됨)를 호출하고 싶습니다.CustomBinding 끝점이있는 클라이언트에서 웹 서비스를 호출하는 방법은 무엇입니까?
는 서비스 계약은 다음과 같습니다
:<system.serviceModel>
<bindings>
<customBinding>
<binding name="NewBinding0">
<textMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<services>
<service name="DiscoveryWebService.DiscoveryService">
<endpoint address="" binding="customBinding" bindingConfiguration="NewBinding0"
contract="DiscoveryWebService.IDiscoveryService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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>
클라이언트 응용 프로그램 코드는 다음과 같습니다처럼
[ServiceContract(Namespace = "http://schemas.microsoft.com/windows/management/2012/01/enrollment")]
[XmlSerializerFormat]
public interface IDiscoveryService
{
[OperationContract(Name = "Get")]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat=WebMessageFormat.Xml, ResponseFormat=WebMessageFormat.Xml)]
string DiscoveryGet();
}
web.config 파일의 내용이 보인다
string uri = " http://localhost/EnrollmentServer/Discovery.svc"; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri); req.ContentType = "unknown"; req.Method = "GET"; WebResponse response = req.GetResponse(); StreamReader loResponseStream = new StreamReader(response.GetResponseStream(), false); string responseString = loResponseStream.ReadToEnd();
Get 메소드가 반환 한 문자열 대신 WSDL 파일의 HTML 내용을 가져오고 있습니다. 내가 올바른 방향으로하고 있는지 여부를 알 수는 없습니까?
이 점에 대해 도움을 주시면 감사하겠습니다.
"carlosfigueira"가 제공 한 아래 답변을 시도했습니다. 웹 서비스가 WCF 테스트 클라이언트와도 작동하지 않는 경우에도 이러한 변경 사항이있는 것으로 보입니다. –