none
WCF Client call webservices success but can't get the resoult RRS feed

  • Question

  • I create a project with .net 4.5 and add webservice reference.http://10.30.47.133:80/LYHG/CRM/DailyDemandPlan/service/PS/LYHG_CRM_DailyDemanPlan?wsdl

    I call the service with below code, the code will be runing success. and the server has recieved the request. the server will return a response But I can't get the response from server in my code. because the response object is null;How can I get the right response object or get the Response xml?

    S_LHYG_ERPSD_DailyDemanPlanPortTypeClient client = new S_LHYG_ERPSD_DailyDemanPlanPortTypeClient();
     iSO_recvDailyDemanPlanRequest request = new iSO_recvDailyDemanPlanRequest();
    SO_recvDailyDemanPlanResponse response = client.iSO_recvDailyDemanPlan(request);

    The code send Envelope

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ZC22_LHP0_SDIF010 xmlns="urn:sap-com:document:sap:rfc:functions"/></s:Body></s:Envelope>

    The server response

    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><cus:ZC22_LHP0_SDIF010.Response xmlns="urn:sap-com:document:sap:rfc:functions.response" xmlns:cus="http://customdefine">
       <cus:E_MESSAGE>数据不能为空</cus:E_MESSAGE>
       <cus:E_TYPE>E</cus:E_TYPE>
       <cus:T_INPUT/>
       <cus:T_RETURN/>
    </cus:ZC22_LHP0_SDIF010.Response></soap-env:Body></soapenv:Envelope>

    web service wsdl

    <?xml version="1.0" encoding="UTF-8"?>
    <WL5G3N0:definitions name="LYHG_DailyDemanPlan_WSDL" targetNamespace="http://www.petrochina.com.cn/LYHG/ERP/service/DailyDemanPlanV1.0" xmlns:WL5G3N0="http://schemas.xmlsoap.org/wsdl/" xmlns:WL5G3N1="urn:sap-com:document:sap:rfc:functions" xmlns:WL5G3N2="urn:sap-com:document:sap:rfc:functions.response" xmlns:WL5G3N3="http://www.petrochina.com.cn/LYHG/ERP/service/DailyDemanPlanV1.0" xmlns:WL5G3N4="http://schemas.xmlsoap.org/wsdl/soap/">
      <WL5G3N0:types>
        <xsd:schema elementFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:rfcReq="urn:sap-com:document:sap:rfc:functions" xmlns:rfcRes="urn:sap-com:document:sap:rfc:functions.response" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.petrochina.com.cn/LYHG/ERP/service/DailyDemanPlanV1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <xsd:element name="ZC22_LHP0_SDIF010">
            <xsd:complexType>
              <xsd:all>
                <xsd:element minOccurs="0" name="T_INPUT">
                  <xsd:complexType>
                    <xsd:sequence>
                      <xsd:element maxOccurs="unbounded" minOccurs="0" name="item" type="rfc:ZC22SDIF010"/>
                    </xsd:sequence>
                  </xsd:complexType>
                </xsd:element>
              </xsd:all>
            </xsd:complexType>
          </xsd:element>
          <xsd:complexType name="ZC22SDIF010">
            <xsd:sequence>
              <xsd:element minOccurs="0" name="ZXQBH">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="10"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="AUART">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="4"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VKORG">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="4"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VKBUR">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="4"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VTWEG">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="2"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="SPART">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="2"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VKGRP">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="3"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="KUNNR">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="10"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZKUNNR">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="10"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VSBED">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="2"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="MATNR">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="18"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="WERKS">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="4"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="LGORT">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="4"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="KWMENG">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:decimal">
                    <xsd:totalDigits value="15"/>
                    <xsd:fractionDigits fixed="true" value="3"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VRKME">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="3"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="VSART">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="2"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZDEPARTURE">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="7"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZDESTINATION">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="7"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZCAR_TYP">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="1"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZCAR_NUM">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="7"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZGC_NUM">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="7"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZCHYS_NUM">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="5"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:schema>
        <xsd:schema elementFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions.response" xmlns:rfc="urn:sap-com:document:sap:rfc:functions.response" xmlns:rfcReq="urn:sap-com:document:sap:rfc:functions" xmlns:rfcRes="urn:sap-com:document:sap:rfc:functions.response" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.petrochina.com.cn/LYHG/ERP/service/DailyDemanPlanV1.0" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <xsd:element name="ZC22_LHP0_SDIF010.Response">
            <xsd:complexType>
              <xsd:all>
                <xsd:element minOccurs="0" name="E_MESSAGE" type="xsd:string"/>
                <xsd:element minOccurs="0" name="E_TYPE">
                  <xsd:simpleType>
                    <xsd:restriction base="xsd:string">
                      <xsd:maxLength value="1"/>
                    </xsd:restriction>
                  </xsd:simpleType>
                </xsd:element>
                <xsd:element minOccurs="0" name="T_RETURN">
                  <xsd:complexType>
                    <xsd:sequence>
                      <xsd:element maxOccurs="unbounded" minOccurs="0" name="item" type="rfc:ZC22SDIF010_RETURN"/>
                    </xsd:sequence>
                  </xsd:complexType>
                </xsd:element>
              </xsd:all>
            </xsd:complexType>
          </xsd:element>
          <xsd:complexType name="ZC22SDIF010_RETURN">
            <xsd:sequence>
              <xsd:element minOccurs="0" name="ZMESSAGE">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="255"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
              <xsd:element minOccurs="0" name="ZTYPE">
                <xsd:simpleType>
                  <xsd:restriction base="xsd:string">
                    <xsd:maxLength value="1"/>
                  </xsd:restriction>
                </xsd:simpleType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:schema>
      </WL5G3N0:types>
      <WL5G3N0:message name="iSO_recvDailyDemanPlanRequestMT">
        <WL5G3N0:part element="WL5G3N1:ZC22_LHP0_SDIF010" name="parameters"/>
      </WL5G3N0:message>
      <WL5G3N0:message name="iSO_recvDailyDemanPlanResponseMT">
        <WL5G3N0:part element="WL5G3N2:ZC22_LHP0_SDIF010.Response" name="parameters"/>
      </WL5G3N0:message>
      <WL5G3N0:portType name="IS_LHYG_ERPSD_DailyDemanPlanPortType">
        <WL5G3N0:operation name="iSO_recvDailyDemanPlan">
          <WL5G3N0:input message="WL5G3N3:iSO_recvDailyDemanPlanRequestMT"/>
          <WL5G3N0:output message="WL5G3N3:iSO_recvDailyDemanPlanResponseMT"/>
        </WL5G3N0:operation>
      </WL5G3N0:portType>
      <WL5G3N0:binding name="IS_LHYG_ERPSD_DailyDemanPlanSOAPBinding" type="WL5G3N3:IS_LHYG_ERPSD_DailyDemanPlanPortType">
        <WL5G3N4:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <WL5G3N0:operation name="iSO_recvDailyDemanPlan">
          <WL5G3N4:operation soapAction="http://www.petrochina.com.cn/LYHG/ERPSD/service/DailyDemanPlan/iSO_recvDailyDemanPlanV1.0"/>
          <WL5G3N0:input>
            <WL5G3N4:body use="literal"/>
          </WL5G3N0:input>
          <WL5G3N0:output>
            <WL5G3N4:body use="literal"/>
          </WL5G3N0:output>
        </WL5G3N0:operation>
      </WL5G3N0:binding>
      <WL5G3N0:service name="IS_LHYG_ERPSD_DailyDemanPlanService">
        <WL5G3N0:port binding="WL5G3N3:IS_LHYG_ERPSD_DailyDemanPlanSOAPBinding" name="IS_LHYG_ERPSD_DailyDemanPlanPort">
          <WL5G3N4:address location="http://10.30.47.133:80/LYHG/CRM/DailyDemandPlan/service/PS/LYHG_CRM_DailyDemanPlan"/>
        </WL5G3N0:port>
      </WL5G3N0:service>
    </WL5G3N0:definitions>

    • Edited by HelloHongfu Thursday, July 28, 2016 7:46 AM add wsdl
    Thursday, July 28, 2016 7:39 AM

Answers

  • Hello HelloHongfu,

    Not sure from the post but I suggest the following:

    • If you can debug the server then set a breakpoint on the return statement to verify that the response is actually returned.  Just in case it is something simple...
    • If you are confident that the response is being returned then set up tracing on the client and server
    • if you see the message bodies in the trace then verify the namespaces are correct.  Unlikely but it could be a situation where the client has an incorrect namespace for the xml being returned and is ignoring the body... unlikely but could happen when refactoring code.

    to set up WCF tracing:

    • https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx
    • http://weblogs.asp.net/seaniannuzzi/wcf-diagnostics-implementation-in-5-easy-steps

    Jeff

    Thursday, July 28, 2016 10:32 PM