C#应用程序通过https连接SAP PI

时间:2017-11-22 11:34:05

标签: c# web-services ssl wsdl sap

我正在开发一个控制台.NET客户端应用程序,通过https频道连接到我们合作伙伴的远程服务器SAP PI。不幸的是,我们遇到了很多问题,我不知道还能做些什么。我会尽力解释,如果有人能帮助我,我会非常感激!

使用SAP PI的远程服务器具有虚构的URL:

https://dev.servereai30.server.com/XISOAPAdapter/MessageServlet?channel=B2B_MYENTERPRISE:PROJECT:SOAP_SND_MYENTERPRISE_Sellout

当我访问URL,提供合作伙伴提供的用户和密码时,服务器似乎正确响应:

urlok

我已经从我的合作伙伴那里收到了wsdl,并且我已经开始开发一个连接Web服务的C#应用​​程序。将wsdl作为服务引用加载后,这是由Visual Studio创建的app.config。

    <?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="CockpitQCWSExtractor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
        </sectionGroup>
    </configSections>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="Sellout_OBBinding">
                    <security mode="Transport">
                        <transport clientCredentialType="Basic"  />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="Sellout_OBBinding1" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://dev.servereai30.server.com/XISOAPAdapter/MessageServlet?channel=B2B_MYENTERPRISE:PROJECT:SOAP_SND_MYENTERPRISE_Sellout"
                binding="basicHttpBinding" bindingConfiguration="Sellout_OBBinding"
                contract="SellOutWSDL.Sellout_OB" name="Sellout_OBPort" />
        </client>
    </system.serviceModel>
</configuration>

这是一个示例应用程序代码:

var wsRefa = new Sellout_OBClient();
wsRefa.ClientCredentials.UserName.UserName = "<user>";
wsRefa.ClientCredentials.UserName.Password = "<password>";
wsRefa.Sellout_OB();

应用程序中断了以下消息:无法为具有权限的SSL / TLS建立安全通道&#39; dev.servereai30.server.com&#39;。我认为问题是服务器证书没有被客户机接受,但我修改了证书通道,一切似乎都没问题。

堆栈跟踪:

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Send(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at CockpitQCWSExtractor.SellOutWSDL.Sellout_OB.Sellout_OB(Sellout_OB1 request)
   at CockpitQCWSExtractor.SellOutWSDL.Sellout_OBClient.CockpitQCWSExtractor.SellOutWSDL.Sellout_OB.Sellout_OB(Sellout_OB1 request) in D:\Users\current.user\cockpit_enterprise\cockpit_ind\cockpit_ind_ws_qc_extractor\cockpit_ind_ws_qc_extractor\Service References\SellOutWSDL\Reference.cs:line 327
   at CockpitQCWSExtractor.SellOutWSDL.Sellout_OBClient.Sellout_OB(SellOutSellOutSpecification[] SellOut) in D:\Users\current.user\cockpit_enterprise\cockpit_ind\cockpit_ind_ws_qc_extractor\cockpit_ind_ws_qc_extractor\Service References\SellOutWSDL\Reference.cs:line 333
   at CockpitQCWSExtractor.Program.Run(Object state) in D:\Users\current.user\cockpit_enterprise\cockpit_ind\cockpit_ind_ws_qc_extractor\cockpit_ind_ws_qc_extractor\Program.cs:line 61
   at CockpitQCWSExtractor.Infrastructure.ProgramStartHelper.MainStart(String[] args, TimerCallback runCallback) in D:\Users\current.user\cockpit_enterprise\cockpit_ind\cockpit_ind_ws_qc_extractor\cockpit_ind_ws_qc_extractor\Infrastructure\ProgramStartHelper.cs:line 32
   at CockpitQCWSExtractor.Program.Main(String[] args) in D:\Users\current.user\cockpit_enterprise\cockpit_ind\cockpit_ind_ws_qc_extractor\cockpit_ind_ws_qc_extractor\Program.cs:line 40
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

有人知道如何解决这个问题吗?

0 个答案:

没有答案
相关问题