请问如何用c#调用这个wsdl的webservice
我用vs2008生成了客户端,但是始终有异常抛出
不能发附件,只能贴代码了
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:tns1="urn:IntegralBasicInfoQuery" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:impl="http://136.5.74.105:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService" xmlns:intf="http://136.5.74.105:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService" targetNamespace="http://136.5.74.105:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:IntegralBasicInfoQuery">
      <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
      <xsd:complexType name="IntegralBasicInfo">
        <xsd:sequence>
          <xsd:element name="consumePoint" nillable="true" type="xsd:string" />
          <xsd:element name="custID" nillable="true" type="xsd:string" />
          <xsd:element name="freezePoint" nillable="true" type="xsd:string" />
          <xsd:element name="newPoint" nillable="true" type="xsd:string" />
          <xsd:element name="note" nillable="true" type="xsd:string" />
          <xsd:element name="totalPoint" nillable="true" type="xsd:string" />
          <xsd:element name="usablePoint" nillable="true" type="xsd:string" />
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="IntegralBasicInfoQueryForCQRequest">
    <wsdl:part name="TimeStamp" type="xsd:string" />
    <wsdl:part name="UserNum" type="xsd:string" />
    <wsdl:part name="UserType" type="xsd:string" />
    <wsdl:part name="BillDate" type="xsd:string" />
    <wsdl:part name="SystemCode" type="xsd:string" />
    <wsdl:part name="Result" type="xsd:int" />
    <wsdl:part name="Status" type="xsd:string" />
    <wsdl:part name="ErrorDescription" type="xsd:string" />
    <wsdl:part name="ExtendField" type="xsd:string" />
  </wsdl:message>
  <wsdl:message name="IntegralBasicInfoQueryForCQResponse">
    <wsdl:part name="IntegralBasicInfoQueryForCQReturn" type="tns1:IntegralBasicInfo" />
    <wsdl:part name="Result" type="xsd:int" />
    <wsdl:part name="Status" type="xsd:string" />
    <wsdl:part name="ErrorDescription" type="xsd:string" />
    <wsdl:part name="ExtendField" type="xsd:string" />
  </wsdl:message>
  <wsdl:portType name="IntegralImpl">
    <wsdl:operation name="IntegralBasicInfoQueryForCQ" parameterOrder="TimeStamp UserNum UserType BillDate SystemCode Result Status ErrorDescription ExtendField">
      <wsdl:input name="IntegralBasicInfoQueryForCQRequest" message="intf:IntegralBasicInfoQueryForCQRequest" />
      <wsdl:output name="IntegralBasicInfoQueryForCQResponse" message="intf:IntegralBasicInfoQueryForCQResponse" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="AIIntegralBasicInfoQueryForCQServiceSoapBinding" type="intf:IntegralImpl">
    <wsdlsoap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
    <wsdl:operation name="IntegralBasicInfoQueryForCQ">
      <wsdlsoap:operation soapAction="" />
      <wsdl:input name="IntegralBasicInfoQueryForCQRequest">
        <wsdlsoap:body use="encoded" namespace="http://webservice.asiainfo.com" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:input>
      <wsdl:output name="IntegralBasicInfoQueryForCQResponse">
        <wsdlsoap:body use="encoded" namespace="http://136.5.74.105:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="IntegralImplService">
    <wsdl:port name="AIIntegralBasicInfoQueryForCQService" binding="intf:AIIntegralBasicInfoQueryForCQServiceSoapBinding">
      <wsdlsoap:address location="http://136.5.74.105:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

解决方案 »

  1.   

    <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:IntegralBasicInfoQueryForCQ xmlns:q1="http://webservice.asiainfo.com"><TimeStamp xsi:type="xsd:string">2010-07-29 19:13:48</TimeStamp><UserNum xsi:type="xsd:string">18996000729</UserNum><UserType xsi:type="xsd:string">1</UserType><BillDate xsi:type="xsd:string">2010-07</BillDate><SystemCode xsi:type="xsd:string">001</SystemCode><Result xsi:type="xsd:int">-1</Result><Status xsi:type="xsd:string"/><ErrorDescription xsi:type="xsd:string"/><ExtendField xsi:type="xsd:string"/></q1:IntegralBasicInfoQueryForCQ></s:Body></s:Envelope>
    这个是用网络工具截下来的消息,感觉是有问题的,和我用java发过去的正常请求不一样未处理 System.ServiceModel.FaultException
      Message="无效的数字签名!; nested exception is: \n\tjava.lang.Exception: 无效的标签:<sec:IntegralImplService>"
      Source="mscorlib"
      StackTrace:
        Server stack trace: 
           在 System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
           在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
           在 System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
           在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
           在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        Exception rethrown at [0]: 
           在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
           在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
           在 OdsWebService.OdsServiceReference.IntegralImpl.IntegralBasicInfoQueryForCQ(IntegralBasicInfoQueryForCQRequest request)
           在 OdsWebService.OdsServiceReference.IntegralImplClient.OdsWebService.OdsServiceReference.IntegralImpl.IntegralBasicInfoQueryForCQ(IntegralBasicInfoQueryForCQRequest request) 位置 D:\Visual Studio 2008\Projects\OdsWebService\OdsWebService\OdsWebService\Service References\OdsServiceReference\Reference.cs:行号 251
           在 OdsWebService.OdsServiceReference.IntegralImplClient.IntegralBasicInfoQueryForCQ(String TimeStamp, String UserNum, String UserType, String BillDate, String SystemCode, Int32& Result, String& Status, String& ErrorDescription, String& ExtendField) 位置 D:\Visual Studio 2008\Projects\OdsWebService\OdsWebService\OdsWebService\Service References\OdsServiceReference\Reference.cs:行号 265
           在 OdsWebService.Form1.confirm_Click(Object sender, EventArgs e) 位置 D:\Visual Studio 2008\Projects\OdsWebService\OdsWebService\OdsWebService\Form1.cs:行号 27
           在 System.Windows.Forms.Control.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnClick(EventArgs e)
           在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           在 System.Windows.Forms.Control.WndProc(Message& m)
           在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
           在 System.Windows.Forms.Button.WndProc(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           在 System.Windows.Forms.Application.Run(Form mainForm)
           在 OdsWebService.Program.Main() 位置 D:\Visual Studio 2008\Projects\OdsWebService\OdsWebService\OdsWebService\Program.cs:行号 18
           在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           在 System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    这个是异常
      

  2.   

    <?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"><soapenv:Header><sec:IntegralImplService soapenv:mustUnderstand="0" xmlns:sec="http://136.5.211.210:9080/AIIntegralWeb/services/AIIntegralBasicInfoQueryForCQService"><sec:digest>42b7eb05df4bdce96754528e651827f1</sec:digest></sec:IntegralImplService></soapenv:Header><soapenv:Body><ns1:IntegralBasicInfoQueryForCQ soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://webservice.asiainfo.com"><TimeStamp xsi:type="xsd:string">2010-07-29 17:52:45</TimeStamp><UserNum xsi:type="xsd:string">800004356928</UserNum><UserType xsi:type="xsd:string">2</UserType><BillDate xsi:type="xsd:string">2009-08</BillDate><SystemCode xsi:type="xsd:string">001</SystemCode><Result href="#id0"/><Status xsi:type="xsd:string" xsi:nil="true"/><ErrorDescription xsi:type="xsd:string" xsi:nil="true"/><ExtendField xsi:type="xsd:string" xsi:nil="true"/></ns1:IntegralBasicInfoQueryForCQ><multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">-1</multiRef></soapenv:Body></soapenv:Envelope>
    这个是正确的消息
      

  3.   

    自己再顶一下,免得沉了,以前搞java的,现在刚开始搞c
      

  4.   

    好像你的wsdl有问题。
    wsdl中并没有关于SoapHeader的描述我有个webservice用C#写的也需要soapheader.它的wsdl中包含<wsdl:input>
      <soap:body use="literal" /> 
      <soap:header message="tns:GetPurchasedExtrasAuthHeader" part="AuthHeader" use="literal" /> 
      </wsdl:input>其它地方有对AuthHeader的定义。
      

  5.   

    好像你的wsdl有问题。
    wsdl中并没有关于SoapHeader的描述我有个webservice用C#写的也需要soapheader.它的wsdl中包含<wsdl:input>
      <soap:body use="literal" /> 
      <soap:header message="tns:GetPurchasedExtrasAuthHeader" part="AuthHeader" use="literal" /> 
      </wsdl:input>其它地方有对AuthHeader的定义。
      

  6.   

    首先确认下,你的webservice 能否访问,再次,确认下能访问的webservice中你想要访问的方法是否能产生有内容的xml文件,如果可以的话。就可以调用webservice
      

  7.   

    这个wsdl是我从web上下载下来的,并且这个web服务我以前用java开发的客户端可以正常访问