I am facing a situation with a 3rd party web service that I need to call. When I make a reference to the web service, I get the following configuration in my app.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GetCompanyInfoSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="GetCompanyInfoSoap1" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
开发者_开发知识库 </binding>
</basicHttpBinding>
<customBinding>
<binding name="GetCompanyInfoSoap12">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpsTransport>
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://api.capitaliq.com/ciqdotnet/api/2.0/GetCompanyInfo.asmx"
binding="basicHttpBinding" bindingConfiguration="GetCompanyInfoSoap"
contract="GetCompanyInfoSvc.GetCompanyInfoSoap" name="GetCompanyInfoSoap" />
<endpoint address="https://api.capitaliq.com/ciqdotnet/api/2.0/GetCompanyInfo.asmx"
binding="customBinding" bindingConfiguration="GetCompanyInfoSoap12"
contract="GetCompanyInfoSvc.GetCompanyInfoSoap" name="GetCompanyInfoSoap12" />
</client>
</system.serviceModel>
Then I call the service using my std. approach as shown:
GetCompanyInfoSvc.GetCompanyInfoSoapClient p = new WindowsFormsApplication1.GetCompanyInfoSvc.GetCompanyInfoSoapClient("GetCompanyInfoSoap");
p.ClientCredentials.UserName.UserName = "cccccc";
p.ClientCredentials.UserName.Password = "ccccg";
GetCompanyInfoSvc.CompanySummary[] summ = p.GetCompanyInfo(new int[] { 18511 });
However, the call always fails with 'Authentication Required' which seems like the username/pw are not getting through. I have tried the std. approach of adding it as an ASMX web reference and used the call:
GetCompanyInfo c = new GetCompanyInfo();
c.Credentials = new System.Net.NetworkCredential("ccccc", "cccg");
CompanyDetail[] details = c.GetCompanyDetail(new int[] { 18511 });
This doesn't work either. Gives me the same 'Authentication required' error.
Is there anything that I am missing?
精彩评论