3
votes

I have consume java web service to my asp.net project by right click and adding service reference.

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

But it has a exception like that:

System.ServiceModel.FaultException :{"Fault occurred while processing."} Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) 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 salim.HakedisService.getCities(getCities request) at salim.HakedisServiceClient.salim.HakedisService.getCities(getCities request) in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\bdbbd757\4abd3cb7\App_WebReferences.mggi9qhe.0.cs:line 1392 at salim.HakedisServiceClient.getCities() in c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\website1\bdbbd757\4abd3cb7\App_WebReferences.mggi9qhe.0.cs:line 1398 at _Default.Page_Load(Object sender, EventArgs e) in c:\Users\htsapp\Documents\Visual Studio 2008\WebSites\WebSite1\Default.aspx.cs:line 80 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

And webservice like that:

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

Anyone have suggest?

1
Try using a tool like Fiddler to see what data is really flowing back and forth. You may also get a better error message in the underlying response that .NET is not picking up.mellamokb
Can you add the contents of that StackTrace?Chris Shain
I cant read the text in the images. But it does not look like Java to me at all.Hauke Ingmar Schmidt
Why are you adding both ClientCredentials.UserName and ClientCredentials.Windows?mellamokb
Can you successfully call the service using a stand alone tool like SoapUI? It's hard to say from the screenshots but there might be an error on the java end.Andrew Walters

1 Answers

2
votes

Try to set your connection up as follows:

 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.

Hope it helps (you can debug through at first).