0

I'm developing a WCF service which should work with two clients: one is a native .Net client through netTcp binding, and ne written on Python.

I need to implement duplex communication between WCF service and native .Net client but it is not necessary for Python client.

I'm trying to implement one service contract for both. Just to keep things easier for me. Because it is duplex service I'm forced to use wsDualHttpBinding to communicate with Python.

On Python side I'm using Zeep library for consuming WCF service.

My service starts up, work with native .Net client. Zeep also can see it`s contract, and call one of it methods. Simple method Ping, which returns string "Pong".

The problem is that .Net client receives "Pong", but Python client always receive null.

I've googled about a little bit and I suppose that the problem is in kind of encoding between WCF service and Python. But i`ve got no idea how configure WCF service or Python Zeep client so they will communicate properly.

WCF service config:

<system.serviceModel>
    <services>
        <service name="NewAsterService.NewAsterService" behaviorConfiguration ="servicebehavior">
            <endpoint address="NewAsterServiceDualHttp" binding="wsDualHttpBinding" contract="NewAsterService.INewAsterService">
            </endpoint>
            <endpoint address="NewAsterServiceTcp" binding="netTcpBinding" contract="NewAsterService.INewAsterService" />
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://192.168.111.101:10001/" />
                    <add baseAddress="net.tcp://192.168.111.101:10002" />
                </baseAddresses>
            </host>
        </service>
    </services>

    <behaviors>
        <serviceBehaviors>
            <behavior name="servicebehavior">
                <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
                <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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="True" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="restBehavior">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>

WCF service contract

    [ServiceContract(CallbackContract = typeof(INewAsterServiceCallbacks))]
public interface INewAsterService //: INewAsterServiceHttpOnly
{
    [OperationContract]
    string Ping();
}

Python script:

import zeep

from zeep import Client, Settings

wsdl_url = "http://192.168.111.34:10001/?WSDL"

settings = Settings(xml_huge_tree=True)
client = Client(wsdl=wsdl_url, settings=settings, )

result = client.service.Ping()

I've tried different variants of attributes in WCF contract: WebGet, WebInvoke, etc. No luck.

Does anyone have any idea how to set this things up?

1 Answers1

0

You can change to a different binding and continue to use zeep to see if it works. If so, zeep is not compatible with wsDualHttpBinding.

In addition how about suds ? py 2.x choose suds and py 3.x choose suds-py3. Maybe this case will help you.

Jiayao
  • 510
  • 3
  • 7
  • Executing "python -m zeep ...\WSDL" gives a successefull description of my service. Command executes. That`s why I consider that zeep is compatible with my service and I need just to reconfigure client or host. I can't choose another binding, because I need duplex communication with other side and it's supported only by wsDual. Otherwise I'll need to split service in two contracts and it could be a little headake. I'll leave it as last solution. Why not suds: zeep seems to be more alive than suds-py3. – Алексей К. Apr 03 '23 at 08:06
  • suds came out earlier than zeep, and may be more ecological and compatible, or used to. – Jiayao Apr 07 '23 at 02:19