I am writing for the first time something related to wcf, I did everything according to the documentation, etc., but I do not understand why my client does not want to receive data from the service. Moreover, it only accepts data, from the service itself I do not call methods in the client, does it mean that I have one-way wsHttpBinding?
The task is as follows: the service receives from the client the matrix size (5x5) and enum identifier for determining how to generate the matrix itself, a random matrix of the specified dimension is generated on the server and returns Matrix <double>
to the client.
Then this matrix will again be transferred to the service for operations with it.
The problem is that I get the following message when the matrix is returned to the client and the error is in the line where the GetMatrix method is called.
An error occurred while receiving the HTTP response to http://localhost:8080/WCF_TRSPO/Service1/. This could be due to the service endpoint binding not using the HTTP protocol.
ServiceTrace says me that error:
The message with To 'http://localhost:8080/WCF_TRSPO/Service1/mex/mex' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
Look, if I pass to the client not the matrix, but null, then the client accepts it. The 5x5 matrix refuses. Similarly, Vector <double>
.
I don’t understand what the problem is, Google search did not return results. Give though directions where to look or where I was wrong?)
Service App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="WCF_TRSPO_Lib.Service1">
<endpoint address="" binding="wsHttpBinding" contract="WCF_TRSPO_Lib.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/WCF_TRSPO/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Client App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/WCF_TRSPO/Service1/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
Service interface
[ServiceContract]
public interface IService1
{
[OperationContract]
ObjectObgortka GetMatrixData(int n, MatrixEnum Letter);
Service Data source where data set return to client
[DataContract]
public class ObjectObgortka
{
public ObjectObgortka()
{
_Matrix = null;
_Vector = null;
}
public Matrix<double> _Matrix;
public Vector<double> _Vector;
[DataMember]
public Matrix<double> Matrix { get { return _Matrix; } set { _Matrix = value; } }
[DataMember]
public Vector<double> Vector { get { return _Vector; } set { _Vector = value; } }
Service
public class Service1 : IService1
{
public ObjectObgortka GetMatrixData(int n, MatrixEnum Letter)
{
MatrixFactory matrixFactory = new MatrixFactory();
ObjectObgortka obgortka = new ObjectObgortka();
Console.WriteLine(n);
obgortka.Matrix = matrixFactory.GetMatrix(Letter, n);
//obgortka.Matrix = null;
return obgortka;
}
and Client
public static void Main(string[] args)
{
//Step 1: Create an instance of the WCF proxy.
Service1Client client = new Service1Client();
// Step 2: Call the service operations.
// Call the Add service operation.
Console.Write("N: ");
int n = Convert.ToInt32(Console.ReadLine());
var matrixA = client.GetMatrixData(n, MatrixEnum.A); //here var is ObjectObgortka type from Servic
Matrix<double> MatrixA = matrixA.Matrix;