我正在从控制台应用程序调用 Web 服务 ( https://gw.sam.gov/epls/services/EPLSSearchWebService?wsdl )。我只需要运行带有 SSN 和名称的“doSsnSearch”并确认是否有成功的返回结果。在我的 30 条测试记录中,有 29 条没有返回任何内容,但是当有有效响应时,服务会抛出异常并且永远不会返回响应。例外情况如下:
Error in deserializing body of reply message for operation 'doSsnSearch'.
内部异常是:
{"Cannot assign object of type System.String[] to an object of type System.String."}
我正在使用服务引用来添加 WSDL,并尝试增加 readerquotas 中所有内容的大小以及我在配置端能想到的所有其他内容。最糟糕的是我之前修复了它,但现在我忘记了我做了什么:\
我已确认 Web 服务调用与我通过使用 SoapUI 提供的数据一起使用,并且我能够获得有效的响应。
这是调用代码:
var client = new EPLSSearchWebServiceClient();
var query = new OperationSsnSearch
{
exactName = "XXX",
ssnOrTin = "xxxxxxxxx"
};
var response = Client.doSsnSearch(query); <--- exception is thrown here
这是我的 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="EPLSSearchWebServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="999999" maxBufferPoolSize="999999" maxReceivedMessageSize="999999" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="999999" maxStringContentLength="999999" maxArrayLength="999999" maxBytesPerRead="999999" maxNameTableCharCount="999999" />
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://gw.sam.gov/epls/services/EPLSSearchWebService" binding="basicHttpBinding" bindingConfiguration="EPLSSearchWebServiceSoapBinding"
contract="SAMWebServices.EPLSSearchWebService" name="EPLSSearchWebService"/>
</client>
</system.serviceModel>
...
非常感谢任何建议。
谢谢
编辑:这是我正在调用的服务的主体:
public SAM_Caller.Console_App.SAMWebServices.EPLSSearchResponse doSsnSearch(SAM_Caller.Console_App.SAMWebServices.OperationSsnSearch query) {
SAM_Caller.Console_App.SAMWebServices.doSsnSearchRequest inValue = new SAM_Caller.Console_App.SAMWebServices.doSsnSearchRequest();
inValue.query = query;
SAM_Caller.Console_App.SAMWebServices.doSsnSearchResponse retVal = ((SAM_Caller.Console_App.SAMWebServices.EPLSSearchWebService)(this)).doSsnSearch(inValue);
return retVal.doSsnSearchReturn;
}