G
G
Gennady Kruglov2018-01-28 18:35:37
C++ / C#
Gennady Kruglov, 2018-01-28 18:35:37

How to run methods of one WCF service from another?

Just started learning about WCF services.
The essence of the task is as follows:
There is a site that must access the methods of an already existing service - A, but it cannot do this directly.
To do this, you need to create an intermediary service - B, whose methods - just have to run the methods of service A and return the result to the site.
I started by adding a link to the wsdl file of service A to the project where service B will be located.
5a6dec47c3f90777378615.png
Then I created a new service by adding a new svc file and an interface to the project that describes all its methods.
Then I added a link to service A in the new service and in the constructor of the new service I create an instance of its client (in order to access its methods through it)
5a6ded371cad0910014004.png
When I try to start this new service, I get an error about a name conflict
5a6ded90ddf04059792910.png
Perhaps I initially approached the task completely wrong and do not understand the essence of WCF, I would be glad if you tell me in which direction to move.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Borovik, 2018-01-28
@PushMeNow

if I'm not mistaken, you need to pass the endpoint string to the constructor, otherwise the service will not start. I myself did not create services, but I have experience of connecting to the mvc project. when connecting to a project, a block like this is created in the web.config file:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="TubeServiceSoap" maxBufferSize="" maxReceivedMessageSize="" sendTimeout="00:05:00" />
      </basicHttpBinding>
      <customBinding>
        <binding name="TubeServiceSoap12">
          <textMessageEncoding messageVersion="Soap12" />
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="путь к сервису" binding="basicHttpBinding" bindingConfiguration="TubeServiceSoap" contract="TubeServiceSlezhLVL2.TubeServiceSoap" name="TubeServiceSoap" />
      <endpoint address="путь к сервису" binding="customBinding" bindingConfiguration="TubeServiceSoap12" contract="TubeServiceSlezhLVL2.TubeServiceSoap" name="TubeServiceSoap12" />
    </client>
  </system.serviceModel>

that endpoint (name) is specified in the client block. Further, this string must be passed to the initialization of the service. try looking in the project configurations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question