3

右クリックしてサービス参照を追加することで、asp.net プロジェクトに Java Web サービスを使用しました。

public static salim.HakedisServiceClient ws = new salim.HakedisServiceClient("HakedisServiceImplPort"); ws.ClientCredentials.UserName.UserName = "****"; ws.ClientCredentials.UserName.Password = "****"; var lstCities = ws.getCities();

ただし、次のような例外があります。

System.ServiceModel.FaultException :{"処理中にエラーが発生しました。"} サーバー スタック トレース: System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime 操作、ProxyRpc& rpc) で System.ServiceModel.Channels.ServiceChannel.Call(String アクション、 Boolean oneway、ProxyOperationRuntime 操作、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 操作) System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage メッセージ) で

[0] で例外が再スローされました: System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) で System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 タイプ) で salim.HakedisService. c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\bdbbd757\4abd3cb7\App_WebReferences.mggi9qhe の salim.HakedisServiceClient.salim.HakedisService.getCities(getCities 要求) での getCities(getCities 要求) .0.cs: c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\bdbbd757\4abd3cb7\App_WebReferences.mggi9qhe.0.cs の salim.HakedisServiceClient.getCities() の 1392 行目: System.Web の c:\Users\htsapp\Documents\Visual Studio 2008\WebSites\WebSite1\Default.aspx.cs:line 80 の _Default.Page_Load(Object sender, EventArgs e) の行 1398。Util.CalliHelper.EventArgFunctionCaller(IntPtr fp、オブジェクト o、オブジェクト t、EventArgs e) で System.Web.Util.CalliEventHandlerDelegateProxy.Callback(オブジェクト送信者、EventArgs e) で System.Web.UI.Control.OnLoad(EventArgs e) でSystem.Web.UI.Control.LoadRecursive() で System.Web.UI.Page.ProcessRequestMain (ブール値 includeStagesBeforeAsyncPoint、ブール値 includeStagesAfterAsyncPoint)

そしてそのようなWebサービス:

<wsdl:definitions name="Hakedis"    targetNamespace="http://hakedis.eventhandler.archibus.com/">
<wsdl:types></wsdl:types>
<wsdl:message name="getFloors"></wsdl:message>
<wsdl:message name="getRooms"></wsdl:message>
<wsdl:message name="getBuildingPropertiesResponse"></wsdl:message>
<wsdl:message name="getBuildingProperties"></wsdl:message>
<wsdl:message name="getBuildingTypes"></wsdl:message>
<wsdl:message name="getBuildingTypesResponse"></wsdl:message>
<wsdl:message name="getFloorsResponse"></wsdl:message>
<wsdl:message name="getRoomsResponse"></wsdl:message>
<wsdl:message name="getCities"></wsdl:message>
<wsdl:message name="getCitiesResponse"></wsdl:message>
<wsdl:message name="getBuildingsResponse"></wsdl:message>
<wsdl:message name="getBuildings"></wsdl:message>
<wsdl:portType name="HakedisService"></wsdl:portType>
<wsdl:binding name="HakedisSoapBinding" type="tns:HakedisService"></wsdl:binding>      <wsdl:service name="Hakedis"></wsdl:service></wsdl:definitions>

誰かが提案していますか?

4

1 に答える 1

2

次のように接続を設定してみてください。

 HakedisServiceClient client = null;
            ChannelEndpointElement endpoint = null;

            ClientSection clientSection = ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;              
            ChannelEndpointElementCollection endpointCollection = clientSection.ElementInformation.Properties[string.Empty].Value as ChannelEndpointElementCollection;
            foreach (ChannelEndpointElement endpointElement in endpointCollection)
            {
                if (endpointElement.Name == "BasicHttpBinding_HakedisService") //BasicHttpBinding_HakedisService from your  config file client endpoint  entries
                {
                    endpoint = endpointElement;
                }
            }

            if (endpoint != null)
            {

                BasicHttpBinding binding = new BasicHttpBinding(endpoint.Name);

                binding.SendTimeout = TimeSpan.FromMinutes(1); //Set all this as appropriate
                binding.OpenTimeout = TimeSpan.FromMinutes(1);
                binding.CloseTimeout = TimeSpan.FromMinutes(1);
                binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
                binding.AllowCookies = false;
                binding.BypassProxyOnLocal = false;
                binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
                binding.MessageEncoding = WSMessageEncoding.Text;
                binding.TextEncoding = System.Text.Encoding.UTF8;
                binding.TransferMode = TransferMode.Buffered;
                binding.UseDefaultWebProxy = true;
                binding.MaxBufferSize = 100000; //as large as needed
                binding.MaxReceivedMessageSize = 100000; //as large as needed
                binding.TextEncoding = Encoding.UTF8;


                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(endpoint.Address.AbsoluteUri);
                SSLAccessPolicy.AllowSSLConnection();
                client = new HakedisServiceClient(binding, address);

                SSLAccessPolicy.AllowSSLConnection(); // only if ssl enabled
                client.Open(); // Now open the client socket.

お役に立てば幸いです(最初はデバッグできます)。

于 2012-07-27T12:12:21.067 に答える