简体   繁体   English

通过C#连接到Cerberus FTP API

[英]Connect to Cerberus FTP API through C#

I'm currently trying to integrate the functionality of Cerberus FTP in our application. 我目前正在尝试在我们的应用程序中集成Cerberus FTP的功能。 Because I couldn't get it to work in my application, I downloaded the available sample which you can download on their website. 由于无法在我的应用程序中使用它,因此我下载了可用的示例 ,您可以在其网站上下载该示例 Unfortunately I can't get it to work either. 不幸的是我也无法正常工作。

After adding the reference an app.config is created: 添加引用后,将创建一个app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="CerberusFTPServiceSoapBinding">
                <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                    messageVersion="Soap12" writeEncoding="utf-8">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>
                <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
                    maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Basic"
                    bypassProxyOnLocal="true" hostNameComparisonMode="StrongWildcard"
                    keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                    realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                    useDefaultWebProxy="true">
                    <extendedProtectionPolicy policyEnforcement="Never" />
                </httpTransport>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:10000/service/cerberusftpservice"
            binding="customBinding" bindingConfiguration="CerberusFTPServiceSoapBinding"
            contract="ServiceCerberusFtpSoap.CerberusFTPServicePort" name="CerberusFTPServicePort" />
    </client>
</system.serviceModel>

I've changed the endpoint address to "https://ipaddressofourserver:10000/service/cerberusftpservice" but then I get the following error: "Unhandled Exception: System.ArgumentException: The provided URI scheme 'https' is invalid; expected 'http'." 我已将端点地址更改为“ https:// ipaddressofourserver:10000 / service / cerberusftpservice”,但随后出现以下错误:“未处理的异常:System.ArgumentException:提供的URI方案'https'无效;应为'http '。” (yes, it needs to be HTTPS). (是的,它必须是HTTPS)。

If I search on this topic you get a lot of articles but the most of them mention to add the following to the app.config: <security mode="Transport"> But I can't choose this mode, I even can't choose "mode"... the only option is authenticationMode. 如果我在该主题上进行搜索,则会收到大量文章,但其中大多数文章提到将以下内容添加到app.config中: <security mode="Transport">但我无法选择此模式,甚至无法选择“模式” ...唯一的选择是authenticationMode。 Some of the possibilities are CertificateOverTransport, KerberosOverTransport, UsernameOverTransport. 一些可能性是CertificateOverTransport,KerberosOverTransport,UsernameOverTransport。

If I choose UsernameOverTransport, I get the following error: "Unhandled Exception: System.InvalidOperationException: The 'CustomBinding'.'http://tempuri.org/' binding for the 'CerberusFTPServicePort'.'http://cerberusllc.com/service/cerberusftpservice' contract is configured with an authentication mode that requires transport level integrity and confidentiality. However the transport cannot provide integrity and confidentiality." 如果选择UsernameOverTransport,则会出现以下错误:“未处理的异常:System.InvalidOperationException:'CerberusFTPServicePort'的'CustomBinding'。'http://tempuri.org/'绑定。'http://cerberusllc.com/ service / cerberusftpservice的合同配置有要求传输级别完整性和机密性的身份验证模式,但是传输无法提供完整性和机密性。”

Is there someone who already worked with the Cerberus FTP API? 是否已经有人使用Cerberus FTP API? How can I use HTTPS to connect to a webservice? 如何使用HTTPS连接到Web服务?

The created app.config was correct. 创建的app.config是正确的。 I needed to set the URL in the code itself like this: 我需要像这样在代码本身中设置URL:

CerberusFTPService client = new CerberusFTPService();
client.Url = "http://ipaddressoftheserver:10000/wsdl/Cerberus.wsdl";

After specifying the URL of the WSDL in the code, I could connect without any problem. 在代码中指定WSDL的URL之后,我可以毫无问题地进行连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM