C# Application connecting SAP PI over https

I'm developing a console .NET client application to connect to our partner's remote server SAP PI over a https channel. Unfortunately we've faced many problems and I'm not sure what more to do. I will try explain as best as I can and if someone could help me I'd be very grateful!

The remote server using SAP PI has the fictitious URL:

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

When I access the URL, providing user and password given by our partners, the server seems to respond correctly:

urlok

I've received the wsdl from my partner and I've started developing a C# application to connect to Web Service. After loading wsdl as a Service Reference this is the app.config created by Visual Studio.

    <?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>

And this is a sample application code:

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

The application breaks with the message: Could not establish secure channel for SSL/TLS with authority 'dev.servereai30.server.com'. I thought the problem was that the server certificate wasn't being accepted by the client machine, but I revised the certificate channel and everything seems fine.

The Stack Trace:

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:Userscurrent.usercockpit_enterprisecockpit_indcockpit_ind_ws_qc_extractorcockpit_ind_ws_qc_extractorService ReferencesSellOutWSDLReference.cs:line 327
   at CockpitQCWSExtractor.SellOutWSDL.Sellout_OBClient.Sellout_OB(SellOutSellOutSpecification[] SellOut) in D:Userscurrent.usercockpit_enterprisecockpit_indcockpit_ind_ws_qc_extractorcockpit_ind_ws_qc_extractorService ReferencesSellOutWSDLReference.cs:line 333
   at CockpitQCWSExtractor.Program.Run(Object state) in D:Userscurrent.usercockpit_enterprisecockpit_indcockpit_ind_ws_qc_extractorcockpit_ind_ws_qc_extractorProgram.cs:line 61
   at CockpitQCWSExtractor.Infrastructure.ProgramStartHelper.MainStart(String[] args, TimerCallback runCallback) in D:Userscurrent.usercockpit_enterprisecockpit_indcockpit_ind_ws_qc_extractorcockpit_ind_ws_qc_extractorInfrastructureProgramStartHelper.cs:line 32
   at CockpitQCWSExtractor.Program.Main(String[] args) in D:Userscurrent.usercockpit_enterprisecockpit_indcockpit_ind_ws_qc_extractorcockpit_ind_ws_qc_extractorProgram.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()

Does someone have an idea how solve this problem?

链接地址: http://www.djcxy.com/p/17184.html

上一篇: SQLite和子

下一篇: C#应用程序通过https连接SAP PI