한 서비스에 메시지를 보내고 다른 서비스에서 응답을 받아들이는 프로그램을 작성하려고합니다. send 서비스는 다른 개발자가 이미 작성 했으므로 내 작업은 해당 sendMessage 서비스에 요청을 보내고 내 서비스 (AcceptMessage) 서비스에 응답을 기록하는 것입니다.로컬로 호스팅 된 WCF 클래스 라이브러리
WCF 클래스 라이브러리를 작성하여 Windows 양식 프로젝트에서 호스트하려고했습니다. 여기
는 내가 가지고있는 구조입니다프로젝트라는 1 -WCF 클래스 라이브러리 - AcceptMessage
프로젝트 2 - SendMessageservice에 서비스 참조 및 참조가있는 Windows 양식 내 서비스 클래스 라이브러리를 승인하십시오. 이 프로젝트는 수락 메시지 서비스도 호스팅합니다. I가 요청을 전송하고 확인 여기서 메시지
private void btnSendMessage_Click_1(object sender, EventArgs e) { var client = new SendMessageService.OperatorClient(); //SendUNIMessage params - Transaction Type and Message Byte result = client.SendUNIMessage("Add", txtRequest.Text); txtResponse.Text = result == 0 ? "Request sent - Success" : "Request sent - Failed"; }
의 Web.config 올바르게 전송된다면
개인 무효를 Form1_Load (객체 송신자있는 EventArgs e)는 {
ServiceHost host = new ServiceHost(typeof(Operator)); BindingElementCollection bec = new BindingElementCollection(); SymmetricSecurityBindingElement ssbe = new SymmetricSecurityBindingElement(); ssbe.LocalServiceSettings.InactivityTimeout = new TimeSpan(0, 10, 0); bec.Add(ssbe); bec.Add(new TextMessageEncodingBindingElement()); bec.Add(new HttpsTransportBindingElement()); CustomBinding customBinding = new CustomBinding(bec); host.AddServiceEndpoint(typeof(AcceptService.Operator), customBinding, BaseAddress); }
이 제품은
<appSettings> <!--<add key="AcceptMessageServiceAddress" value="http:/localhost/AcceptService"/>--> <add key="AcceptMessageServiceAddress" value="http://localhost/AcceptService"/> </appSettings> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="UNI.Endpoint.Basic" /> </basicHttpBinding> </bindings> <client> <endpoint address="http://insomeotherserver/sendmessage.asmx" binding="basicHttpBinding" bindingConfiguration="UNI.Endpoint.Basic" contract="SendMessageService.IOperator" name="UNI.Endpoint.Basic" /> </client> <behaviors> <serviceBehaviors> <behavior name="TestAcceptService.IOperator"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="TestAcceptService.AcceptServiceBehavior" name="TestAcceptService.AcceptService"> <endpoint address="" binding="wsHttpBinding" contract="TestAcceptService.IOperator"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost/AcceptService" /> </baseAddresses> </host> </service>
문제는 내가 보내는 서비스에 메시지를 보낼 수 있지만 내 중단 점이 운영자라는 Acceptmessage 서비스 클래스에 부딪히지 않는다는 것입니다. 그것이 내 로컬 드라이브에 대한 모든 응답을 기록하는 곳입니다.
내 양식 클라이언트 프로젝트에서 서비스를 연결하려고 시도했지만 도움이되지 않았습니다.
도움 주셔서 감사합니다.