您好我正在尝试在c# console application
中使用WSDL soap服务,该服务会传递一个帐号并返回该帐户的详细信息。
我已经使用SOAP UI测试了服务,一切都很好并且正在工作但是现在当我使用svcutil
创建服务类来生成类时,我实例化客户端并尝试调用该方法但它失败并显示以下错误消息。请帮助我请参阅下面的错误消息和代码。
inner exception : There is an error in the XML document(43,9)
message : Input string was not in a correct format.
以下代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
namespace CRMTestApp
{
class Program
{
static void Main(string[] args)
{
var myBinding = new BasicHttpBinding();
var myednPoint = new EndpointAddress("SERVICE URL");
var myChannelFactory = new ChannelFactory<customerDetail_PortType>(myBinding, myednPoint);
customerDetail_PortType client = null;
try
{
getCustomerDetailsRequest request = new getCustomerDetailsRequest();
request.customerDetailIn = new customerDetailIn();
request.customerDetailIn.emmAccountNo = "3902269211";
//request.customerDetailIn.IDNumber = String.Empty;
//request.customerDetailIn.standNo = String.Empty;
client = myChannelFactory.CreateChannel();
client.getCustomerDetails(request);
//client.getCustomerDetails()
((ICommunicationObject)client).Close();
}
catch (Exception ex)
{
if (client != null)
{
((ICommunicationObject)client).Abort();
}
}
}
}
}
这是我的app.config文件
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EMMCRMIntegration_webServices_providers_customerDetail_Binder" />
<readerQuotas maxDepth="999999" maxStringContentLength="999999" maxArrayLength="999999" maxBytesPerRead="999999" maxNameTableCharCount="999999" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="SERVICE URL"
binding="basicHttpBinding"
bindingConfiguration="EMMCRMIntegration_webServices_providers_customerDetail_Binder"
contract="customerDetail_PortType"
name="EMMCRMIntegration_webServices_providers_customerDetail_Port"
/>
</client>
</system.serviceModel>
</configuration>
我真的很感谢你的帮助。我试了一个小时来解决这个问题,但没有运气。