How to programmatically connect to a WCF service hosted in IIS

The connections and client endpoints of my WCF service hosted in IIS appear below.

<bindings>
    <customBinding>
          <binding name="notSecureBinding">
              <binaryMessageEncoding />
              <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
          </binding>
          <binding name="SecureBinding">
              <binaryMessageEncoding />
              <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
          </binding>
      </customBinding>
  </bindings>



<client>
      <endpoint address="http://ServerName.myDomain.org/ADSearcher/Service1.svc"
                binding="customBinding"
                bindingConfiguration="notSecureBinding"
                contract="GetData.GetData"
                name="notSecureBinding" />

      <endpoint address="https://ServerName.myDomain.org/ADSearcher/Service1.svc"
                binding="customBinding"
                bindingConfiguration="SecureBinding"
                contract="GetData.GetData"
                name="SecureBinding" />
  </client>

Now what I want to do is connect to this service and read the data I want without adding any service links to my asp.net mvc 4 application.

I tried this code below

BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
EndpointAddress endpointAddress = new EndpointAddress("http://ServerName.myDomain.org/ADSearcher/Service1.svc");
IService1 ADUser = new ChannelFactory<IService1>(basicHttpBinding, endpointAddress).CreateChannel();
DataTable ADUserInfo = ADUser.GetADUserList(strUserName, strFirstName, strLastName, strEmail, domain);

But the above code throws an error below.

" http://tempuri.org/IService1/GetADUserList ' - ContractFilter EndpointDispatcher. - ( ) / . , ( , , , ).

, WCF "customBinding", , # "BasicHttpBinding".

- , IIS WCF- # GetADUserList MVC?

+4
1

CustomBinding System.ServiceModel, .

Binding customBinding = new CustomBinding(
             new BinaryMessageEncodingBindingElement(),
             new HttpTransportBindingElement 
             { 
               MaxReceivedMessageSize = 2147483647, 
               MaxBufferSize = 2147483647 
             });
EndpointAddress endpointAddress = new EndpointAddress("http://ServerName.myDomain.org/ADSearcher/Service1.svc");
IService1 ADUser = new ChannelFactory<IService1>(customBinding, endpointAddress).CreateChannel();
0

All Articles