在C#中消耗SAP WebService的问题

时间:2015-02-18 12:44:15

标签: c# web-services sap webservice-client

几个小时后我尝试从我的小C#win-test-app中使用web服务。 我使用标准机制来使用Web服务("添加服务参考")。然后我能够使用自动生成的代码创建客户端。但是,当我调用webservice的一个方法时,我收到以下错误消息:

"提供的URI方案' http'是无效的;预期' https'。参数名称:via"

以下是该服务的wsdl:



<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:n1="urn:sap-com:document:sap:rfc:functions">
  <wsdl:documentation>
    <sidl:sidl xmlns:sidl="http://www.sap.com/2007/03/sidl"/>
  </wsdl:documentation>
  <wsp:UsingPolicy wsdl:required="true"/>
  <wsp:Policy wsu:Id="BN__ZICO_SO_CREATE">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
        <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
        <wsp:All xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
          <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
      <wsp:All>
        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" wsp:Optional="true"/>
        <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
        <wsp:All xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
          <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="BN__ZICO_SO_CREATE_soap12">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedMimeSerialization xmlns:saptrnbnd="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization" wsp:Optional="true"/>
        <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
        <wsp:All xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
          <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
      <wsp:All>
        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">false</sapattahnd:Enabled>
        <saptrnbnd:OptimizedXMLTransfer uri="http://xml.sap.com/2006/11/esi/esp/binxml" xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/" wsp:Optional="true"/>
        <wsaw:UsingAddressing xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" wsp:Optional="true"/>
        <wsp:All xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
          <sp:TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702" xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
            <wsp:Policy>
              <sp:TransportToken>
                <wsp:Policy>
                  <sp:HttpsToken>
                    <wsp:Policy>
                      <sp:HttpBasicAuthentication/>
                    </wsp:Policy>
                  </sp:HttpsToken>
                </wsp:Policy>
              </sp:TransportToken>
              <sp:AlgorithmSuite>
                <wsp:Policy>
                  <sp:Basic128Rsa15/>
                </wsp:Policy>
              </sp:AlgorithmSuite>
              <sp:Layout>
                <wsp:Policy>
                  <sp:Strict/>
                </wsp:Policy>
              </sp:Layout>
            </wsp:Policy>
          </sp:TransportBinding>
        </wsp:All>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="IF__ZICO_SO_CREATE">
    <wsp:ExactlyOne>
      <wsp:All>
        <sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">
          <sapsession:enableSession>false</sapsession:enableSession>
        </sapsession:Session>
        <sapcentraladmin:CentralAdministration xmlns:sapcentraladmin="http://www.sap.com/webas/700/soap/features/CentralAdministration/" wsp:Optional="true">
          <sapcentraladmin:BusinessApplicationID>005056B643B81ED4A8B050998153F728</sapcentraladmin:BusinessApplicationID>
        </sapcentraladmin:CentralAdministration>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsp:Policy wsu:Id="OP__ZicoSoCreate">
    <wsp:ExactlyOne>
      <wsp:All>
        <saptrhnw05:required xmlns:saptrhnw05="http://www.sap.com/NW05/soap/features/transaction/">no</saptrhnw05:required>
        <sapcomhnd:enableCommit xmlns:sapcomhnd="http://www.sap.com/NW05/soap/features/commit/">false</sapcomhnd:enableCommit>
        <sapblock:enableBlocking xmlns:sapblock="http://www.sap.com/NW05/soap/features/blocking/">true</sapblock:enableBlocking>
        <saprmnw05:enableWSRM xmlns:saprmnw05="http://www.sap.com/NW05/soap/features/wsrm/">false</saprmnw05:enableWSRM>
      </wsp:All>
    </wsp:ExactlyOne>
  </wsp:Policy>
  <wsdl:types>
    <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:rfc:functions">
      <xsd:simpleType name="char1">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="1"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char10">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="10"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char12">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="12"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char18">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="18"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char2">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="2"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char20">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="20"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char220">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="220"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="char4">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="4"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="date10">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="10"/>
          <xsd:pattern value="\d\d\d\d-\d\d-\d\d"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="numeric3">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="3"/>
          <xsd:pattern value="\d*"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="numeric6">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="6"/>
          <xsd:pattern value="\d*"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="quantum13.3">
        <xsd:restriction base="xsd:decimal">
          <xsd:totalDigits value="13"/>
          <xsd:fractionDigits value="3"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="time">
        <xsd:restriction base="xsd:time">
          <xsd:pattern value="[0-9]{2}:[0-9]{2}:[0-9]{2}"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType name="unit3">
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="3"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:schema>
    <xsd:schema attributeFormDefault="qualified" targetNamespace="urn:sap-com:document:sap:soap:functions:mc-style" xmlns:n0="urn:sap-com:document:sap:rfc:functions">
      <xsd:import namespace="urn:sap-com:document:sap:rfc:functions"/>
      <xsd:complexType name="ZicoWsSsSo">
        <xsd:sequence>
          <xsd:element name="Sdhd1" type="tns:ZicoWsSsSdhd1"/>
          <xsd:element name="Parnr" type="tns:ZicoWsSsParnrTt"/>
          <xsd:element name="Sditm" type="tns:ZicoWsSsSditmTt"/>
          <xsd:element name="Schdl" type="tns:ZicoWsSsSchdlTt"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsSdhd1">
        <xsd:sequence>
          <xsd:element name="DocType" type="n0:char4"/>
          <xsd:element name="SalesOrg" type="n0:char4"/>
          <xsd:element name="DistrChan" type="n0:char2"/>
          <xsd:element name="Division" type="n0:char2"/>
          <xsd:element name="ReqDateH" type="n0:date10"/>
          <xsd:element name="CreatedBy" type="n0:char12"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsParnr">
        <xsd:sequence>
          <xsd:element name="ItmNumber" type="n0:numeric6"/>
          <xsd:element name="PartnRole" type="n0:char2"/>
          <xsd:element name="PartnNumb" type="n0:char10"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsSchdl">
        <xsd:sequence>
          <xsd:element name="ItmNumber" type="n0:numeric6"/>
          <xsd:element name="ReqQty" type="n0:quantum13.3"/>
          <xsd:element name="ReqDate" type="n0:date10"/>
          <xsd:element name="ReqDateFrom" type="n0:date10"/>
          <xsd:element name="ReqDateTo" type="n0:date10"/>
          <xsd:element name="ReqTimeFrom" type="n0:time"/>
          <xsd:element name="ReqTimeTo" type="n0:time"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsSditm">
        <xsd:sequence>
          <xsd:element name="ItmNumber" type="n0:numeric6"/>
          <xsd:element name="Material" type="n0:char18"/>
          <xsd:element name="Plant" type="n0:char4"/>
          <xsd:element name="StoreLoc" type="n0:char4"/>
          <xsd:element name="SalesUnit" type="n0:unit3"/>
          <xsd:element name="TargetQu" type="n0:unit3"/>
          <xsd:element name="TargetQty" type="n0:quantum13.3"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsMsg">
        <xsd:sequence>
          <xsd:element name="Type" type="n0:char1"/>
          <xsd:element name="Id" type="n0:char20"/>
          <xsd:element name="Number" type="n0:numeric3"/>
          <xsd:element name="Message" type="n0:char220"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsParnrTt">
        <xsd:sequence>
          <xsd:element name="item" type="tns:ZicoWsSsParnr" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsSchdlTt">
        <xsd:sequence>
          <xsd:element name="item" type="tns:ZicoWsSsSchdl" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsSditmTt">
        <xsd:sequence>
          <xsd:element name="item" type="tns:ZicoWsSsSditm" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:complexType name="ZicoWsSsMsgTt">
        <xsd:sequence>
          <xsd:element name="item" type="tns:ZicoWsSsMsg" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="ZicoSoCreate">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="IsSoData" type="tns:ZicoWsSsSo"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="ZicoSoCreateResponse">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="ESoNumber" type="n0:char10"/>
            <xsd:element name="EtMessages" type="tns:ZicoWsSsMsgTt"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="ZicoSoCreate">
    <wsdl:part name="parameters" element="tns:ZicoSoCreate"/>
  </wsdl:message>
  <wsdl:message name="ZicoSoCreateResponse">
    <wsdl:part name="parameter" element="tns:ZicoSoCreateResponse"/>
  </wsdl:message>
  <wsdl:portType name="ZICO_SO_CREATE">
    <wsp:Policy>
      <wsp:PolicyReference URI="#IF__ZICO_SO_CREATE"/>
    </wsp:Policy>
    <wsdl:operation name="ZicoSoCreate">
      <wsp:Policy>
        <wsp:PolicyReference URI="#OP__ZicoSoCreate"/>
      </wsp:Policy>
      <wsdl:input message="tns:ZicoSoCreate"/>
      <wsdl:output message="tns:ZicoSoCreateResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ZICO_SO_CREATE" type="tns:ZICO_SO_CREATE">
    <wsp:Policy>
      <wsp:PolicyReference URI="#BN__ZICO_SO_CREATE"/>
    </wsp:Policy>
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="ZicoSoCreate">
      <soap:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:ZICO_SO_CREATE:ZicoSoCreateRequest" style="document"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:binding name="ZICO_SO_CREATE_soap12" type="tns:ZICO_SO_CREATE">
    <wsp:Policy>
      <wsp:PolicyReference URI="#BN__ZICO_SO_CREATE_soap12"/>
    </wsp:Policy>
    <wsoap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="ZicoSoCreate">
      <wsoap12:operation soapAction="urn:sap-com:document:sap:soap:functions:mc-style:ZICO_SO_CREATE:ZicoSoCreateRequest" style="document"/>
      <wsdl:input>
        <wsoap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <wsoap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ZICO_SO_CREATE">
    <wsdl:port name="ZICO_SO_CREATE" binding="tns:ZICO_SO_CREATE">
      <soap:address location="http://ICODCCSD01.ICODCC.local:8000/sap/bc/srt/rfc/sap/zico_so_create/200/zico_so_create/zico_so_create"/>
    </wsdl:port>
    <wsdl:port name="ZICO_SO_CREATE_soap12" binding="tns:ZICO_SO_CREATE_soap12">
      <wsoap12:address location="http://ICODCCSD01.ICODCC.local:8000/sap/bc/srt/rfc/sap/zico_so_create/200/zico_so_create/zico_so_create"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>
&#13;
&#13;
&#13;

这是我的app.config中生成的代码:

&#13;
&#13;
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="ZICO_SO_CREATE">
          <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style':    -->
          <!--    <wsdl:binding name='ZICO_SO_CREATE'>    -->
          <!--        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled>    -->
          <mtomMessageEncoding messageVersion="Soap11WSAddressing10" />
          <httpsTransport authenticationScheme="Basic" />
        </binding>
        <binding name="ZICO_SO_CREATE_soap12">
          <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style':    -->
          <!--    <wsdl:binding name='ZICO_SO_CREATE_soap12'>    -->
          <!--        <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled>    -->
          <mtomMessageEncoding />
          <httpsTransport authenticationScheme="Basic" />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="http://ICODCCSD01.ICODCC.local:8000/sap/bc/srt/rfc/sap/zico_so_create/200/zico_so_create/zico_so_create" binding="customBinding" bindingConfiguration="ZICO_SO_CREATE" contract="ZICO_SO_CREATE" name="ZICO_SO_CREATE" />
      <endpoint address="http://ICODCCSD01.ICODCC.local:8000/sap/bc/srt/rfc/sap/zico_so_create/200/zico_so_create/zico_so_create" binding="customBinding" bindingConfiguration="ZICO_SO_CREATE_soap12" contract="ZICO_SO_CREATE" name="ZICO_SO_CREATE_soap12" />
    </client>
  </system.serviceModel>
</configuration>
&#13;
&#13;
&#13;

这是我的C#代码:

&#13;
&#13;
			try
			{
				ZICO_SO_CREATEClient client = new ZICO_SO_CREATEClient("ZICO_SO_CREATE_soap12");
				client.ClientCredentials.UserName.UserName = "myuser";
				client.ClientCredentials.UserName.Password = "mypassword";
				client.ClientCredentials.HttpDigest.ClientCredential.UserName = "myuser";
				client.ClientCredentials.HttpDigest.ClientCredential.Password = "mypassword";
				ZicoSoCreate zico = new ZicoSoCreate();
				zico.IsSoData = new ZicoWsSsSo();
				zico.IsSoData.Sdhd1 = new ZicoWsSsSdhd1();
				zico.IsSoData.Sdhd1.DocType = "OTA";
				ZicoWsSsParnr[] parNr = new ZicoWsSsParnr[1];
				parNr[0] = new ZicoWsSsParnr();
				parNr[0].ItmNumber = "123456";
				zico.IsSoData.Parnr = parNr;
				ZicoWsSsSditm[] values = new ZicoWsSsSditm[4];
				// Unleaded
				AddZicoWsSsSditmValue(values, 0, "110", "500");
				// PremiumUnleaded
				AddZicoWsSsSditmValue(values, 1, "210", "600");
				// Diesel
				AddZicoWsSsSditmValue(values, 2, "310", "700");
				// PremiumDiesel
				AddZicoWsSsSditmValue(values, 3, "410", "800");
				zico.IsSoData.Sditm = values;
				ZicoSoCreateResponse response = client.ZicoSoCreate(zico);
				string result = "";
				foreach (ZicoWsSsMsg msg in response.EtMessages)
				{
					result += msg.Id + ":" + msg.Message + ":" + msg.Number + ":" + msg.Type + "#";
				}
				MessageBox.Show(result);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
&#13;
&#13;
&#13;

如您所见,Web服务需要用户名/密码身份验证。 欢迎任何帮助或建议。 亲切的问候 贝恩德

2 个答案:

答案 0 :(得分:0)

更改为httpTransport而非httpsTransport

答案 1 :(得分:0)

将TransportBinding WS-SecurityPolicy从v1.2更改为v1.3

TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"...

TransportBinding xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802"...