Портирование библиотеки c # wcf на Python - PullRequest
0 голосов
/ 01 октября 2019

Я пытаюсь портировать ac # WCF-оболочку, способную использовать WSDL-сервис, на python. Я пытался использовать Zeep, но это не работает.

Это мой код Python:

from requests import Session
from requests_ntlm import HttpNtlmAuth

from zeep import Client
from zeep.transports import Transport

username = 'DESKTOP-IF71P86\Federico'  # domain\username
password = 'SlackWare777'
wsdl = 'http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService?wsdl' # url for soap service

# Connect
session = Session()
session.auth = HttpNtlmAuth(username, password)
client = Client(wsdl, transport=Transport(session=session))

# Request
obj = {'Message':{'RegistrationID': None, 'RegisterService': None}}
response = client.service.XmlCommand(**obj)

после выполнения этого кода я не получаю никакого ответа.

При отладке моего приложения на c # я 'мы получаем сообщение такого типа:

<Message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.bio-rad.com/LSG/GXD/CfxComSchema.xsd">
  <RegistrationID />
  <RegisterService />
</Message>

с таким ответом:

<?xml version=\"1.0\" encoding=\"utf-16\"?>
\r\n
<Blocks xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://schemas.bio-rad.com/LSG/GXD/CfxComSchema.xsd\">\r\n  
<CFXManagerVersion>4.1.2433.1219</CFXManagerVersion>\r\n  <User>admin</User>\r\n 
 <RegistrationID>eb4dde34-b258-4b88-a27c-acca04d92036</RegistrationID>\r\n  
<BlockArray>\r\n    <SerialNumber>SIM90800</SerialNumber>\r\n    <Status>Idle</Status>\r\n    <Step>1</Step>\r\n    <Steps>0</Steps>\r\n    <Cycle>1</Cycle>\r\n    <Cycles>1</Cycles>\r\n    <SampleVolume>\r\n      <Volume>0</Volume>\r\n      <Units>MicroLiter</Units>\r\n    </SampleVolume>\r\n    <LidTemperature>\r\n      <Temperature>105</Temperature>\r\n      <Units>Celcius</Units>\r\n    </LidTemperature>\r\n    <BlockTemperature>\r\n      <Temperature>25.1</Temperature>\r\n      <Units>Celcius</Units>\r\n    </BlockTemperature>\r\n    <EstimatedRemainingRunTime>0</EstimatedRemainingRunTime>\r\n    <NickName />\r\n    <Description>CFX96</Description>\r\n    <Rows>8</Rows>\r\n    <Columns>12</Columns>\r\n    <Letter>A</Letter>\r\n    <Dual>false</Dual>\r\n    <RealTime>true</RealTime>\r\n    <Manufacturer>BIO-RAD LABORATORIES</Manufacturer>\r\n    <Simulated>true</Simulated>\r\n    <RipFolder />\r\n    <MotorizedLidPosition>CLOSED</MotorizedLidPosition>\r\n    <BlockID>4</BlockID>\r\n    <ShippingScrewInstalled>false</ShippingScrewInstalled>\r\n    <SerialNumbers>\r\n      <Base>SIM90800</Base>\r\n      <Block>RN001744</Block>\r\n      <Shuttle>SG3091</Shuttle>\r\n      <OpticalHead>788BR00467</OpticalHead>\r\n    </SerialNumbers>\r\n    <FirmwareVersions>\r\n      <PXA270>1.101.422.0514</PXA270>\r\n      <FX2>1.35</FX2>\r\n      <HC12>1.0.165.0 Rev A</HC12>\r\n      <DSP>1.124</DSP>\r\n      <LID>54</LID>\r\n    </FirmwareVersions>\r\n  </BlockArray>\r\n</Blocks>

И это объявление службы:

<?xml version="1.0" encoding="ISO-8859-1"?>
<wsdl:definitions xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://BioRad.PCR.CommandManager" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/" name="SOCFXCommandService">
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_policy">
<wsp:ExactlyOne>
<wsp:All>
<wsrm:RMAssertion xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
<wsrm:InactivityTimeout Milliseconds="600000"/>
<wsrm:AcknowledgementInterval Milliseconds="200"/>
</wsrm:RMAssertion>
<sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:ProtectionToken>
<wsp:Policy>
<sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:RequireDerivedKeys/>
<sp:BootstrapPolicy>
<wsp:Policy>
<sp:SignedParts>
<sp:Body/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts>
<sp:Body/>
</sp:EncryptedParts>
<sp:SymmetricBinding>
<wsp:Policy>
<sp:ProtectionToken>
<wsp:Policy>
<sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:RequireDerivedKeys/>
</wsp:Policy>
</sp:SpnegoContextToken>
</wsp:Policy>
</sp:ProtectionToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
<sp:EncryptSignature/>
<sp:OnlySignEntireHeadersAndBody/>
</wsp:Policy>
</sp:SymmetricBinding>
<sp:Wss11>
<wsp:Policy/>
</sp:Wss11>
<sp:Trust10>
<wsp:Policy>
<sp:MustSupportIssuedTokens/>
<sp:RequireClientEntropy/>
<sp:RequireServerEntropy/>
</wsp:Policy>
</sp:Trust10>
</wsp:Policy>
</sp:BootstrapPolicy>
</wsp:Policy>
</sp:SecureConversationToken>
</wsp:Policy>
</sp:ProtectionToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:Layout>
<wsp:Policy>
<sp:Strict/>
</wsp:Policy>
</sp:Layout>
<sp:IncludeTimestamp/>
<sp:EncryptSignature/>
<sp:OnlySignEntireHeadersAndBody/>
</wsp:Policy>
</sp:SymmetricBinding>
<sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy/>
</sp:Wss11>
<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:MustSupportIssuedTokens/>
<sp:RequireClientEntropy/>
<sp:RequireServerEntropy/>
</wsp:Policy>
</sp:Trust10>
<cdp:CompositeDuplex xmlns:cdp="http://schemas.microsoft.com/net/2006/06/duplex"/>
<ow:OneWay xmlns:ow="http://schemas.microsoft.com/ws/2005/05/routing/policy"/>
<wsaw:UsingAddressing/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_SubscribeToServiceIsClosing_Input_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_SubscribeToServiceIsClosing_output_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_XmlCommand_Input_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_XmlCommand_output_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy wsu:Id="WSDualHttpBinding_ISOCFXCommandService_OnServiceIsClosing_output_policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="Sequence"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="SequenceAcknowledgement"/>
<sp:Header Namespace="http://schemas.xmlsoap.org/ws/2005/02/rm" Name="AckRequested"/>
<sp:Header Namespace="http://schemas.microsoft.com/ws/2005/02/duplex" Name="ChannelInstance"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="To"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="From"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="FaultTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="ReplyTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="MessageID"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="RelatesTo"/>
<sp:Header Namespace="http://www.w3.org/2005/08/addressing" Name="Action"/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsdl:import location="http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService?wsdl=wsdl0" namespace="http://BioRad.PCR.CommandManager"/>
<wsdl:types/>
<wsdl:binding type="i0:ISOCFXCommandService" name="WSDualHttpBinding_ISOCFXCommandService">
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_policy"/>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SubscribeToServiceIsClosing">
<soap12:operation style="document" soapAction="http://BioRad.PCR.CommandManager/ISOCFXCommandService/SubscribeToServiceIsClosing"/>
<wsdl:input>
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_SubscribeToServiceIsClosing_Input_policy"/>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_SubscribeToServiceIsClosing_output_policy"/>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="XmlCommand">
<soap12:operation style="document" soapAction="http://BioRad.PCR.CommandManager/ISOCFXCommandService/XmlCommand"/>
<wsdl:input>
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_XmlCommand_Input_policy"/>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_XmlCommand_output_policy"/>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="OnServiceIsClosing">
<soap12:operation style="document" soapAction="http://BioRad.PCR.CommandManager/ISOCFXCommandService/OnServiceIsClosing"/>
<wsdl:output>
<wsp:PolicyReference URI="#WSDualHttpBinding_ISOCFXCommandService_OnServiceIsClosing_output_policy"/>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="SOCFXCommandService">
<wsdl:port name="WSDualHttpBinding_ISOCFXCommandService" binding="tns:WSDualHttpBinding_ISOCFXCommandService">
<soap12:address location="http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService"/>
<wsa10:EndpointReference>
<wsa10:Address>http://localhost:8003/BioRad.PCR.CommandManager/SOCFXCommandService</wsa10:Address>
<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<Upn>DESKTOP-IF71P86\Federico</Upn>
</Identity>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Я новичок вмир мыла, так что я не знаю, что я делаю неправильно. Любое предложение?

...