dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.71k stars 558 forks source link

Error migrating client from Net Framework 4.7.2 to Net 5 #4625

Closed mcNets closed 3 years ago

mcNets commented 3 years ago

Visual Studio 16.9.5

I'm trying to migrate our client classes from Net Framework 4.7.2 to Net 5 and I'm getting an error:

Error in deserializing body of reply message for operation 'read'.

I'm trying to connect to a 3rd party web service that requires pre-authentication, I'm using OperationContextScope to set it.

try
{
    using (OperationContextScope scope = new OperationContextScope(this.x3_ws.InnerChannel))
    {
        var httpRequestProperty = new HttpRequestMessageProperty();
        httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(this.x3_host.user + ":" + this.x3_host.password));
        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;

        ws_result = x3_ws.read(get_call_context(), x3obj.ws_name, x3obj.keys());
    }

    check_ws_error();

    result = true;
}
catch (Exception ex)
{
    this.add_error(ex.Message);

    result = false;
}

This is the payload returned using SoapUI:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wss="http://www.adonix.com/WSS">
   <soapenv:Body>
      <wss:readResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <readReturn xsi:type="wss:CAdxResultXml">
            <messages xsi:type="soapenc:Array" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" soapenc:arrayType="wss:CAdxMessage[0]"/>
            <resultXml xsi:type="xsd:string"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<RESULT>
    <GRP ID="SOH0_1">
        <FLD NAME="SALFCY" TYPE="Char">AIS01</FLD>
        <FLD NAME="SOHTYP" TYPE="Char">AVWS</FLD>
        <FLD NAME="SOHNUM" TYPE="Char">PWEB2000031</FLD>
        <FLD NAME="CUSORDREF" TYPE="Char"/>
        <FLD NAME="ORDDAT" TYPE="Date">20201118</FLD>
        <FLD NAME="BPCORD" TYPE="Char">CL00256</FLD>
        <FLD NAME="BPCNAM" TYPE="Char">CENTRE ODONTOLOGIC ELS</FLD>
        <FLD NAME="ZUBIREP" TYPE="Char"/>
    </GRP>
    <GRP ID="SOH1_1">
        <FLD NAME="BPAADD" TYPE="Char">001</FLD>
    </GRP>
    <GRP ID="SOH1_2">
        <FLD NAME="PJT" TYPE="Char"/>
    </GRP>
    <GRP ID="SOH2_1">
        <FLD NAME="STOFCY" TYPE="Char">AIS01</FLD>
    </GRP>
    <GRP ID="SOH2_2">
        <FLD NAME="DEMDLVDAT" TYPE="Date">20201119</FLD>
        <FLD NAME="SHIDAT" TYPE="Date">20201118</FLD>
    </GRP>
    <GRP ID="SOH2_3">
        <FLD NAME="BPTNUM" TYPE="Char">ENV19</FLD>
        <FLD NAME="ZBPTNUM" TYPE="Char">ENVIALIA 19H</FLD>
        <FLD NAME="ZHORARIINICI" TYPE="Char">0000</FLD>
        <FLD NAME="ZHORARIFI" TYPE="Char">0000</FLD>
    </GRP>
    <GRP ID="SOH2_8">
        <FLD NAME="ZEMPTRANS" TYPE="Char">ENVIALIA</FLD>
        <FLD NAME="ZSERVTRANS" TYPE="Char">Entrega 19h</FLD>
        <FLD NAME="ZHORAENVIO" TYPE="Char">2020-1</FLD>
        <FLD NAME="ZREFENVIO" TYPE="Char">2020111804PWEB200003</FLD>
    </GRP>
    <GRP ID="SOH3_2">
        <FLD NAME="INVCND" TYPE="Char"/>
        <FLD NAME="VCRINVCNDDAT" TYPE="Date">20201118</FLD>
    </GRP>
    <GRP ID="SOH3_3">
        <FLD NAME="PTE" TYPE="Char">CRDOM_30D_15FM</FLD>
        <FLD NAME="ZPTE" TYPE="Char">C/Recibo domic. 30 días. 15FM</FLD>
    </GRP>
    <GRP ID="ADB2_1">
        <FLD NAME="BPAADD" TYPE="Char">001</FLD>
    </GRP>
    <GRP ID="ADXTEC">
        <FLD NAME="WW_MODSTAMP" TYPE="Char">20201202104708</FLD>
        <FLD NAME="WW_MODUSER" TYPE="Char">MJRI</FLD>
    </GRP>
    <TAB DIM="300" ID="SOH4_1" SIZE="1">
        <LIN NUM="1">
            <FLD NAME="ITMREF" TYPE="Char">0190</FLD>
            <FLD NAME="ITMDES" TYPE="Char">Pilar Transepitelial</FLD>
            <FLD NAME="ZITMDES2" TYPE="Char">EC 4,1 GH1 (Uniblock)</FLD>
            <FLD NAME="QTY" TYPE="Decimal">2</FLD>
            <FLD NAME="GROPRI" TYPE="Decimal">50</FLD>
            <FLD NAME="DISCRGVAL1" TYPE="Decimal">10</FLD>
            <FLD NAME="NETPRI" TYPE="Decimal">45</FLD>
            <FLD NAME="DPJT" TYPE="Char"/>
            <FLD NAME="DSHIDAT" TYPE="Date">20201118</FLD>
        </LIN>
    </TAB>
</RESULT>]]></resultXml>
            <status xsi:type="xsd:int">1</status>
            <technicalInfos xsi:type="wss:CAdxTechnicalInfos">
               <busy xsi:type="xsd:boolean">false</busy>
               <changeLanguage xsi:type="xsd:boolean">true</changeLanguage>
               <changeUserId xsi:type="xsd:boolean">true</changeUserId>
               <flushAdx xsi:type="xsd:boolean">false</flushAdx>
               <loadWebsDuration xsi:type="xsd:double">10</loadWebsDuration>
               <nbDistributionCycle xsi:type="xsd:int">-1</nbDistributionCycle>
               <poolDistribDuration xsi:type="xsd:double">0</poolDistribDuration>
               <poolEntryIdx xsi:type="xsd:int">11688</poolEntryIdx>
               <poolExecDuration xsi:type="xsd:double">893</poolExecDuration>
               <poolRequestDuration xsi:type="xsd:double">-1</poolRequestDuration>
               <poolWaitDuration xsi:type="xsd:double">0</poolWaitDuration>
               <processReport xsi:type="xsd:string" xsi:nil="true"/>
               <processReportSize xsi:type="xsd:int">-1</processReportSize>
               <reloadWebs xsi:type="xsd:boolean">false</reloadWebs>
               <resumitAfterDBOpen xsi:type="xsd:boolean">false</resumitAfterDBOpen>
               <rowInDistribStack xsi:type="xsd:int" xsi:nil="true"/>
               <totalDuration xsi:type="xsd:double">920</totalDuration>
               <traceRequest xsi:type="xsd:string"/>
               <traceRequestSize xsi:type="xsd:int">0</traceRequestSize>
            </technicalInfos>
         </readReturn>
      </wss:readResponse>
   </soapenv:Body>
</soapenv:Envelope>

I'm trying to add the library source code to my project instead of Nuget package, but I'm getting some compiler errors, I think because I don't have all frameworks installed.

And this is WDSL content:

<wsdl:definitions targetNamespace="http://www.adonix.com/WSS" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wss="http://www.adonix.com/WSS" xmlns:intf="http://www.adonix.com/WSS" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)-->
   <wsdl:types>
      <schema targetNamespace="http://www.adonix.com/WSS" xmlns="http://www.w3.org/2001/XMLSchema">
         <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
         <complexType name="CAdxCallContext">
            <sequence>
               <element name="codeLang" nillable="true" type="xsd:string"/>
               <element name="poolAlias" nillable="true" type="xsd:string"/>
               <element name="poolId" nillable="true" type="xsd:string"/>
               <element name="requestConfig" nillable="true" type="xsd:string"/>
            </sequence>
         </complexType>
         <complexType name="CAdxMessage">
            <sequence>
               <element name="message" nillable="true" type="xsd:string"/>
               <element name="type" nillable="true" type="xsd:string"/>
            </sequence>
         </complexType>
         <complexType name="ArrayOfCAdxMessage">
            <complexContent>
               <restriction base="soapenc:Array">
                  <attribute ref="soapenc:arrayType" wsdl:arrayType="wss:CAdxMessage[]"/>
               </restriction>
            </complexContent>
         </complexType>
         <complexType name="CAdxTechnicalInfos">
            <sequence>
               <element name="busy" type="xsd:boolean"/>
               <element name="changeLanguage" type="xsd:boolean"/>
               <element name="changeUserId" type="xsd:boolean"/>
               <element name="flushAdx" type="xsd:boolean"/>
               <element name="loadWebsDuration" type="xsd:double"/>
               <element name="nbDistributionCycle" type="xsd:int"/>
               <element name="poolDistribDuration" type="xsd:double"/>
               <element name="poolEntryIdx" type="xsd:int"/>
               <element name="poolExecDuration" type="xsd:double"/>
               <element name="poolRequestDuration" type="xsd:double"/>
               <element name="poolWaitDuration" type="xsd:double"/>
               <element name="processReport" nillable="true" type="xsd:string"/>
               <element name="processReportSize" type="xsd:int"/>
               <element name="reloadWebs" type="xsd:boolean"/>
               <element name="resumitAfterDBOpen" type="xsd:boolean"/>
               <element name="rowInDistribStack" type="xsd:int"/>
               <element name="totalDuration" type="xsd:double"/>
               <element name="traceRequest" nillable="true" type="xsd:string"/>
               <element name="traceRequestSize" type="xsd:int"/>
            </sequence>
         </complexType>
         <complexType name="CAdxResultXml">
            <sequence>
               <element name="messages" nillable="true" type="wss:ArrayOfCAdxMessage"/>
               <element name="resultXml" nillable="true" type="xsd:string"/>
               <element name="status" type="xsd:int"/>
               <element name="technicalInfos" nillable="true" type="wss:CAdxTechnicalInfos"/>
            </sequence>
         </complexType>
         <complexType name="CAdxParamKeyValue">
            <sequence>
               <element name="key" nillable="true" type="xsd:string"/>
               <element name="value" nillable="true" type="xsd:string"/>
            </sequence>
         </complexType>
         <complexType name="ArrayOfCAdxParamKeyValue">
            <complexContent>
               <restriction base="soapenc:Array">
                  <attribute ref="soapenc:arrayType" wsdl:arrayType="wss:CAdxParamKeyValue[]"/>
               </restriction>
            </complexContent>
         </complexType>
         <complexType name="ArrayOf_xsd_string">
            <complexContent>
               <restriction base="soapenc:Array">
                  <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
               </restriction>
            </complexContent>
         </complexType>
      </schema>
   </wsdl:types>
   <wsdl:message name="queryRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
      <wsdl:part name="listSize" type="xsd:int"/>
   </wsdl:message>
   <wsdl:message name="insertLinesResponse">
      <wsdl:part name="insertLinesReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="getDataXmlSchemaResponse">
      <wsdl:part name="getDataXmlSchemaReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="actionObjectKeysResponse">
      <wsdl:part name="actionObjectKeysReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="deleteRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
   </wsdl:message>
   <wsdl:message name="runRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="inputXml" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="runResponse">
      <wsdl:part name="runReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="queryResponse">
      <wsdl:part name="queryReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="insertLinesRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
      <wsdl:part name="blocKey" type="xsd:string"/>
      <wsdl:part name="lineKey" type="xsd:string"/>
      <wsdl:part name="lineXml" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="getDescriptionResponse">
      <wsdl:part name="getDescriptionReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="deleteLinesRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
      <wsdl:part name="blocKey" type="xsd:string"/>
      <wsdl:part name="lineKeys" type="wss:ArrayOf_xsd_string"/>
   </wsdl:message>
   <wsdl:message name="getDataXmlSchemaRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="actionObjectRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="actionCode" type="xsd:string"/>
      <wsdl:part name="objectXml" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="modifyRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
      <wsdl:part name="objectXml" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="saveResponse">
      <wsdl:part name="saveReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="getDescriptionRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="actionObjectKeysRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="actionCode" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
   </wsdl:message>
   <wsdl:message name="deleteLinesResponse">
      <wsdl:part name="deleteLinesReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="actionObjectResponse">
      <wsdl:part name="actionObjectReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="deleteResponse">
      <wsdl:part name="deleteReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="saveRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectXml" type="xsd:string"/>
   </wsdl:message>
   <wsdl:message name="readRequest">
      <wsdl:part name="callContext" type="wss:CAdxCallContext"/>
      <wsdl:part name="publicName" type="xsd:string"/>
      <wsdl:part name="objectKeys" type="wss:ArrayOfCAdxParamKeyValue"/>
   </wsdl:message>
   <wsdl:message name="readResponse">
      <wsdl:part name="readReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:message name="modifyResponse">
      <wsdl:part name="modifyReturn" type="wss:CAdxResultXml"/>
   </wsdl:message>
   <wsdl:portType name="CAdxWebServiceXmlCC">
      <wsdl:operation name="run" parameterOrder="callContext publicName inputXml">
         <wsdl:input message="wss:runRequest" name="runRequest"/>
         <wsdl:output message="wss:runResponse" name="runResponse"/>
         <wsdl:documentation>Run X3 sub program</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="save" parameterOrder="callContext publicName objectXml">
         <wsdl:input message="wss:saveRequest" name="saveRequest"/>
         <wsdl:output message="wss:saveResponse" name="saveResponse"/>
         <wsdl:documentation>Create X3 object</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="delete" parameterOrder="callContext publicName objectKeys">
         <wsdl:input message="wss:deleteRequest" name="deleteRequest"/>
         <wsdl:output message="wss:deleteResponse" name="deleteResponse"/>
         <wsdl:documentation>Delete X3 object</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="read" parameterOrder="callContext publicName objectKeys">
         <wsdl:input message="wss:readRequest" name="readRequest"/>
         <wsdl:output message="wss:readResponse" name="readResponse"/>
         <wsdl:documentation>Read X3 object</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="query" parameterOrder="callContext publicName objectKeys listSize">
         <wsdl:input message="wss:queryRequest" name="queryRequest"/>
         <wsdl:output message="wss:queryResponse" name="queryResponse"/>
         <wsdl:documentation>Get X3 objects list</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="getDescription" parameterOrder="callContext publicName">
         <wsdl:input message="wss:getDescriptionRequest" name="getDescriptionRequest"/>
         <wsdl:output message="wss:getDescriptionResponse" name="getDescriptionResponse"/>
         <wsdl:documentation>Get X3 web service description regarding publication done in GESAWE</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="modify" parameterOrder="callContext publicName objectKeys objectXml">
         <wsdl:input message="wss:modifyRequest" name="modifyRequest"/>
         <wsdl:output message="wss:modifyResponse" name="modifyResponse"/>
         <wsdl:documentation>Update X3 object</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="actionObject" parameterOrder="callContext publicName actionCode objectXml">
         <wsdl:input message="wss:actionObjectRequest" name="actionObjectRequest"/>
         <wsdl:output message="wss:actionObjectResponse" name="actionObjectResponse"/>
         <wsdl:documentation>Execute specific action on X3 object providing XML flow</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="actionObjectKeys" parameterOrder="callContext publicName actionCode objectKeys">
         <wsdl:input message="wss:actionObjectKeysRequest" name="actionObjectKeysRequest"/>
         <wsdl:output message="wss:actionObjectKeysResponse" name="actionObjectKeysResponse"/>
         <wsdl:documentation>Execute specific action on X3 object providing keys</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="getDataXmlSchema" parameterOrder="callContext publicName">
         <wsdl:input message="wss:getDataXmlSchemaRequest" name="getDataXmlSchemaRequest"/>
         <wsdl:output message="wss:getDataXmlSchemaResponse" name="getDataXmlSchemaResponse"/>
         <wsdl:documentation>Get X3 web service schema regarding publication done in GESAWE</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="insertLines" parameterOrder="callContext publicName objectKeys blocKey lineKey lineXml">
         <wsdl:input message="wss:insertLinesRequest" name="insertLinesRequest"/>
         <wsdl:output message="wss:insertLinesResponse" name="insertLinesResponse"/>
         <wsdl:documentation>NOT YET IMPLEMENTED !!!</wsdl:documentation>
      </wsdl:operation>
      <wsdl:operation name="deleteLines" parameterOrder="callContext publicName objectKeys blocKey lineKeys">
         <wsdl:input message="wss:deleteLinesRequest" name="deleteLinesRequest"/>
         <wsdl:output message="wss:deleteLinesResponse" name="deleteLinesResponse"/>
         <wsdl:documentation>Remove lines from X3 object table</wsdl:documentation>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="CAdxWebServiceXmlCCSoapBinding" type="wss:CAdxWebServiceXmlCC">
      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="run">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="runRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="runResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="save">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="saveRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="saveResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="delete">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="deleteRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="deleteResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="read">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="readRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="readResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="query">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="queryRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="queryResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="getDescription">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getDescriptionRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="getDescriptionResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="modify">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="modifyRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="modifyResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="actionObject">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="actionObjectRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="actionObjectResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="actionObjectKeys">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="actionObjectKeysRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="actionObjectKeysResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="getDataXmlSchema">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="getDataXmlSchemaRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="getDataXmlSchemaResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="insertLines">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="insertLinesRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="insertLinesResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
      <wsdl:operation name="deleteLines">
         <wsdlsoap:operation soapAction=""/>
         <wsdl:input name="deleteLinesRequest">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:input>
         <wsdl:output name="deleteLinesResponse">
            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://www.adonix.com/WSS" use="encoded"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="CAdxWebServiceXmlCCService">
      <wsdl:port binding="wss:CAdxWebServiceXmlCCSoapBinding" name="CAdxWebServiceXmlCC">
         <wsdlsoap:address location="http://192.168.0.51:8124/soap-generic/syracuse/collaboration/syracuse/CAdxWebServiceXmlCC"/>
      </wsdl:port>
      <wsdl:documentation>This SOAP web service allows to call X3 sub programs and/or to manipulate X3 objects trough CRUD and specifics methods</wsdl:documentation>
   </wsdl:service>
</wsdl:definitions>
mconnew commented 3 years ago

It's not clear if the problem is WCF isn't understanding the correct response that was returned or if the error is caused by a response indicating authorization problems. Can you use fiddler to find out which is your problem and then we can go from there. Your code to add the authentication header looks correct to me so I don't think that's your problem.

mcNets commented 3 years ago

Hi @mconnew.

That's the request captured by Fiddler using SoapUI:

POST http://xxx.xxx.xxx.xxx:8124/soap-generic/syracuse/collaboration/syracuse/CAdxWebServiceXmlCC HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Authorization: Basic V1NFUlZJ&898561NFUlZJQ0U=
Content-Length: 817
Host: xxx.xxx.xxx.xxx:8124
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/12.0.1)

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wss="http://www.adonix.com/WSS">
   <soapenv:Header/>
   <soapenv:Body>
      <wss:getDescription soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <callContext xsi:type="wss:CAdxCallContext">
            <codeLang xsi:type="xsd:string">SPA</codeLang>
            <poolAlias xsi:type="xsd:string">WDUMMY</poolAlias>
            <poolId xsi:type="xsd:string">?</poolId>
            <requestConfig xsi:type="xsd:string">adxwss.beautify=true</requestConfig>
         </callContext>
         <publicName xsi:type="xsd:string">ZPREUART</publicName>
      </wss:getDescription>
   </soapenv:Body>
</soapenv:Envelope>

And that using the library:

POST http://xxx.xxx.xxx.xxx:8124/soap-generic/syracuse/collaboration/syracuse/CAdxWebServiceXmlCC HTTP/1.1
Host: xxx.xxx.xxx.xxx:8124
Cache-Control: no-cache, max-age=0
Authorization: Basic V1NFUlZJ&898561NFUlZJQ0U=
SOAPAction: ""
Accept-Encoding: gzip, deflate
Content-Type: text/xml; charset=utf-8
Content-Length: 750

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <q1:getDescription xmlns:q1="http://www.adonix.com/WSS">
      <callContext href="#id1"/>
      <publicName xsi:type="xsd:string">ZWSSOH2</publicName>
    </q1:getDescription>
    <q2:CAdxCallContext id="id1" xsi:type="q2:CAdxCallContext" xmlns:q2="http://www.adonix.com/WSS">
      <codeLang xsi:type="xsd:string">SPA</codeLang>
      <poolAlias xsi:type="xsd:string">WDUMMY</poolAlias>
      <poolId xsi:type="xsd:string"/>
      <requestConfig xsi:type="xsd:string">adxwss.beautify=true</requestConfig>
    </q2:CAdxCallContext>
  </s:Body>
</s:Envelope>

In both cases Auth shows the same value:

Authorization Header is present: Basic V1NFUlZJ&898561NFUlZJQ0U=
Decoded Username:Password= MYUSER:MYPASS

I'm getting an exception in the proxy class:

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=System.Private.CoreLib StackTrace: at System.Runtime.CompilerServices.CastHelpers.Unbox(Void* toTypeHnd, Object obj)

When it try to call this function:

public x3ws.getDescriptionResponse getDescription(x3ws.getDescriptionRequest request)
{
    return base.Channel.getDescription(request);
}

But there is a previous error:

Error in deserializing body of reply message for operation 'getDescription'.

And that is the response using SoapUI:

HTTP/1.1 200 OK
content-type: text/xml; charset=utf-8
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
content-security-policy: frame-ancestors 'self'; 
cache-control: max-age=0, s-maxage=0, no-cache, must-revalidate, private, proxy-revalidate, no-store
pragma: no-cache
Date: Mon, 31 May 2021 09:16:26 GMT
Connection: keep-alive
Content-Length: 2966

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wss="http://www.adonix.com/WSS">
  <soapenv:Body>
    <wss:getDescriptionResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <getDescriptionReturn xsi:type="wss:CAdxResultXml">
        <messages xsi:type="soapenc:Array" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" soapenc:arrayType="wss:CAdxMessage[0]"></messages>
        <resultXml xsi:type="xsd:string">
          <![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<ADXDOC PNA="ZPREUART" TIM="20191023172403" PRG="ZPREUARTICLE" SPG="ZPREUARTICLE" FOL="DUMMYV11" 
SOL="SAGEX3" USER="ADMIN" VER="6.30" HEAD="1" WRP="WJZPREUART" 
C_SPA="Retorna el preu i dte d'un article per un client">
 <ADXDATA>
<GRP PNA="GRP1" NAM="GRP1" DIM="1">
<FLD NAM="ZCPY" IDX="1" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZITM" IDX="2" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZCLI" IDX="3" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZFCY" IDX="4" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZQTY" IDX="5" TYP="Decimal" PAR="Value" MOD="Input"/>
<FLD NAM="ZDT" IDX="6" TYP="Date" PAR="Value" MOD="Input"/>
<FLD NAM="ZPREUNET" IDX="7" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZDTE" IDX="8" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZPREUBRUT" IDX="9" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZTPROHI" IDX="10" TYP="Integer" PAR="Adr" MOD="Input"/>
</GRP>
 </ADXDATA>
 <ADXMEN>
</ADXMEN>
</ADXDOC>
]]>
        </resultXml>
        <status xsi:type="xsd:int">1</status>
        <technicalInfos xsi:type="wss:CAdxTechnicalInfos">
          <busy xsi:type="xsd:boolean">false</busy>
          <changeLanguage xsi:type="xsd:boolean">false</changeLanguage>
          <changeUserId xsi:type="xsd:boolean">false</changeUserId>
          <flushAdx xsi:type="xsd:boolean">false</flushAdx>
          <loadWebsDuration xsi:type="xsd:double">6</loadWebsDuration>
          <nbDistributionCycle xsi:type="xsd:int">-1</nbDistributionCycle>
          <poolDistribDuration xsi:type="xsd:double">0</poolDistribDuration>
          <poolEntryIdx xsi:type="xsd:int">1400</poolEntryIdx>
          <poolExecDuration xsi:type="xsd:double">3</poolExecDuration>
          <poolRequestDuration xsi:type="xsd:double">-1</poolRequestDuration>
          <poolWaitDuration xsi:type="xsd:double">0</poolWaitDuration>
          <processReport xsi:type="xsd:string" xsi:nil="true"/>
          <processReportSize xsi:type="xsd:int">-1</processReportSize>
          <reloadWebs xsi:type="xsd:boolean">false</reloadWebs>
          <resumitAfterDBOpen xsi:type="xsd:boolean">false</resumitAfterDBOpen>
          <rowInDistribStack xsi:type="xsd:int" xsi:nil="true"/>
          <totalDuration xsi:type="xsd:double">12</totalDuration>
          <traceRequest xsi:type="xsd:string"/>
          <traceRequestSize xsi:type="xsd:int">0</traceRequestSize>
        </technicalInfos>
      </getDescriptionReturn>
    </wss:getDescriptionResponse>
  </soapenv:Body>
</soapenv:Envelope>

And that the response using the library:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wss="http://www.adonix.com/WSS">
  <soapenv:Body>
    <wss:getDescriptionResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <getDescriptionReturn xsi:type="wss:CAdxResultXml">
        <messages xsi:type="soapenc:Array" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" soapenc:arrayType="wss:CAdxMessage[0]"></messages>
        <resultXml xsi:type="xsd:string">
          <![CDATA[<?xml version="1.0" encoding="utf-8" ?>
<ADXDOC PNA="ZPREUART" TIM="20191023172403" PRG="ZPREUARTICLE" SPG="ZPREUARTICLE" FOL="DUMMYV11" 
SOL="SAGEX3" USER="ADMIN" VER="6.30" HEAD="1" WRP="WJZPREUART" 
C_SPA="Retorna el preu i dte d'un article per un client">
 <ADXDATA>
<GRP PNA="GRP1" NAM="GRP1" DIM="1">
<FLD NAM="ZCPY" IDX="1" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZITM" IDX="2" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZCLI" IDX="3" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZFCY" IDX="4" TYP="Char" PAR="Value" MOD="Input" LEN="250"/>
<FLD NAM="ZQTY" IDX="5" TYP="Decimal" PAR="Value" MOD="Input"/>
<FLD NAM="ZDT" IDX="6" TYP="Date" PAR="Value" MOD="Input"/>
<FLD NAM="ZPREUNET" IDX="7" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZDTE" IDX="8" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZPREUBRUT" IDX="9" TYP="Decimal" PAR="Adr" MOD="Input"/>
<FLD NAM="ZTPROHI" IDX="10" TYP="Integer" PAR="Adr" MOD="Input"/>
</GRP>
 </ADXDATA>
 <ADXMEN>
</ADXMEN>
</ADXDOC>
]]>
        </resultXml>
        <status xsi:type="xsd:int">1</status>
        <technicalInfos xsi:type="wss:CAdxTechnicalInfos">
          <busy xsi:type="xsd:boolean">false</busy>
          <changeLanguage xsi:type="xsd:boolean">false</changeLanguage>
          <changeUserId xsi:type="xsd:boolean">false</changeUserId>
          <flushAdx xsi:type="xsd:boolean">false</flushAdx>
          <loadWebsDuration xsi:type="xsd:double">5</loadWebsDuration>
          <nbDistributionCycle xsi:type="xsd:int">-1</nbDistributionCycle>
          <poolDistribDuration xsi:type="xsd:double">0</poolDistribDuration>
          <poolEntryIdx xsi:type="xsd:int">10268</poolEntryIdx>
          <poolExecDuration xsi:type="xsd:double">3</poolExecDuration>
          <poolRequestDuration xsi:type="xsd:double">-1</poolRequestDuration>
          <poolWaitDuration xsi:type="xsd:double">0</poolWaitDuration>
          <processReport xsi:type="xsd:string" xsi:nil="true"/>
          <processReportSize xsi:type="xsd:int">-1</processReportSize>
          <reloadWebs xsi:type="xsd:boolean">false</reloadWebs>
          <resumitAfterDBOpen xsi:type="xsd:boolean">false</resumitAfterDBOpen>
          <rowInDistribStack xsi:type="xsd:int" xsi:nil="true"/>
          <totalDuration xsi:type="xsd:double">11</totalDuration>
          <traceRequest xsi:type="xsd:string"/>
          <traceRequestSize xsi:type="xsd:int">0</traceRequestSize>
        </technicalInfos>
      </getDescriptionReturn>
    </wss:getDescriptionResponse>
  </soapenv:Body>
</soapenv:Envelope>

In both cases it is a valid response.

Thanks for your help.

jjakob666 commented 3 years ago

in .net5 code I get an exception accessing client.InnerChannel (in your example OperationContextScope(this.x3_ws.InnerChannel)). Were you able to get this going? I'm trying to add an Authorization header with "Bearer mytoken"

mcNets commented 3 years ago

in .net5 code I get an exception accessing client.InnerChannel (in your example OperationContextScope(this.x3_ws.InnerChannel)). Were you able to get this going? I'm trying to add an Authorization header with "Bearer mytoken"

@jjakob666 yes it woks fine in net5 and netcoreapp3.1

mconnew commented 3 years ago

I worked out the problem. This shouldn't have worked in .NET Framwork either, unless someone modified the code generated by Add Service Reference or svcutil. The problem is an error in your WSDL. If you look at the response, the XML element technicalInfos has a child element called rowInDistribStack. This is the XML in the response:

          <rowInDistribStack xsi:type="xsd:int" xsi:nil="true"/>

You can see there's no value for it, and it specified xsi:nil="true", which means it's not a missing value, it's explicitly there but is null. If you look at the WSDL, the schema definition for the complexType CAdxTechnicalInfos looks like this:

         <complexType name="CAdxTechnicalInfos">
            <sequence>
               <element name="busy" type="xsd:boolean"/>
               <element name="changeLanguage" type="xsd:boolean"/>
               <element name="changeUserId" type="xsd:boolean"/>
               <element name="flushAdx" type="xsd:boolean"/>
               <element name="loadWebsDuration" type="xsd:double"/>
               <element name="nbDistributionCycle" type="xsd:int"/>
               <element name="poolDistribDuration" type="xsd:double"/>
               <element name="poolEntryIdx" type="xsd:int"/>
               <element name="poolExecDuration" type="xsd:double"/>
               <element name="poolRequestDuration" type="xsd:double"/>
               <element name="poolWaitDuration" type="xsd:double"/>
               <element name="processReport" nillable="true" type="xsd:string"/>
               <element name="processReportSize" type="xsd:int"/>
               <element name="reloadWebs" type="xsd:boolean"/>
               <element name="resumitAfterDBOpen" type="xsd:boolean"/>
               <element name="rowInDistribStack" type="xsd:int"/>
               <element name="totalDuration" type="xsd:double"/>
               <element name="traceRequest" nillable="true" type="xsd:string"/>
               <element name="traceRequestSize" type="xsd:int"/>
            </sequence>
         </complexType>

There are a couple of elements with the attribute nillable="true", e.g. traceRequest. Without this attribute, the element isn't allowed to be nil. The element rowInDistribStack doesn't specify nillable="true" which means it's not allowed to specify xsi:nil="true" in the response document, but it does. You need to fix your WSDL and regenerate your client. This is what that line should look like:

               <element name="rowInDistribStack" nillable="true" type="xsd:int"/>

When you generate the WCF proxy client, you will get a property which looks something like this:

        [System.Xml.Serialization.SoapElementAttribute(IsNullable=true)]
        public System.Nullable<int> rowInDistribStack {
            get {
                return this.rowInDistribStackField;
            }
            set {
                this.rowInDistribStackField = value;
                this.RaisePropertyChanged("rowInDistribStack");
            }
        }

This sets the IsNullable property on the SoapElement attribute to true, and also uses Nullable<int> as the data type. This provides you a nullable property where you can tell the difference between xsi:nil="true" or the value being absent (which would have previously left the value as 0, but is now going to be null), and the value 0 being provided.

mcNets commented 3 years ago

Thanks @mconnew

Let me try to manually modify the WSDL file that is generated by a 3rd party software.

I took a look at WSDL generated in .Net Framework and it has same definition:

<xsd:element name="rowInDistribStack" type="xsd:int" />

But it works without any modification.

Again thanks for your time.

mconnew commented 3 years ago

I tested generating a client from the wall on .NET Framework and got the same exception as you are seeing on core. There isn't a behavior difference between NetFx and Core here. This is why I suggested that maybe someone previously edited the generated code in your NetFx app. It's only going to throw an exception if there's a nil value in the response. An integer value won't cause the exception.

mcNets commented 3 years ago

@mconnew Hi.

I've manually modified the WSDL file and then I've generated a new proxy class using this file and it works!

Thanks for your help.