1

I have been consuming a Java Web Services in .net 3.5 but I have seen a lack of performance during the first time the web service proxy is created.

I Added the WebService reference using Add Service reference feature. At this point the WebService reference is created, the next step is to create a proxy instance to consume the Web Service.

The enpoind that I have been using (let's say is is http://crdevelopment/services/SalesService) contains 250 soap methods. So when I try to consume a single WebMehod , ie getCustomersLocation, I do the following line of code

var serviceResult = new SalesProxy(http://crdevelopment/services/SalesService?wsdl);

This line takes long time, I'm assuming it is because the endPoint does has a lot of web methods.

Then , I consume the method

var customerLocations = serviceResult .getCustomersLocation("San Jose").

The execution of the Web Method does not take time, but the proxy creation does.

My question is, Why is the proxy object instance taking long time , even when I have added the Web Service reference and the proxy must have been created?

Does that make sense for you?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Michael Hidalgo
  • 197
  • 3
  • 13
  • I suspect by giving it the URL including `?wsdl` part you make it download and interpret the WSDL which is totally unnecessary... give it the URL to the werbservice and see whether that changes anything... – Yahia Aug 23 '11 at 23:28
  • Thanks, Correct ?wsdl is not part of the URL in the WebService reference constructor. It was used to Discover the Service. – Michael Hidalgo Aug 24 '11 at 19:05

1 Answers1

1

Looks like you have a wrong URL (?wsdl at the end):

var serviceResult = 
       new SalesProxy("http://crdevelopment/services/SalesService?wsdl");

Should not it be something like:

var serviceResult = new SalesProxy("http://crdevelopment/services/SalesService");

If I understood you correctly, you don't need WSDL at runtime because proxy is generated at design time. It may explain the issue because generated proxy might be loading WSDL for no reason and it can cause a delay.

UPDATE:

Looks like you might be experiencing delays related to XML serialization in SoapHttpClientProtocol constructor. See this question, it contains few possible solutions. Additionally you may want to try generating WCF client/proxy and use it instead. You need to use "Add Service Reference", not "Add Web Reference", the difference is outlined here.

Community
  • 1
  • 1
Dmitry
  • 17,078
  • 2
  • 44
  • 70
  • Hi Dmitry, Thanks for your response. You are right, I create the proxy at design time,but I need to consume the WebService at runtime, thats why I have created an instance of the reference class . Does it make sense? – Michael Hidalgo Aug 24 '11 at 19:03
  • You don't need WSDL at runtime. It is only needed at design time to generate proxy. Once your proxy is generated you point it to the URL of the service itself, not to the URL of WSDL. Does it work for you if you change it like I suggest in the answer? – Dmitry Aug 24 '11 at 19:05
  • Yes,there was a mistake in the URL format.The problem shows up when I need to consume a WebMethod.In that case I create an objecto from the Service reference created at design time. I set the URL of the service and this process takes long time. It does not make any sense because the WSDL was created at design mode. – Michael Hidalgo Aug 24 '11 at 19:10
  • I modified the service reference to be able to use Microsoft.Web.Services3.WebServicesClientProtocol, I don't nkow if this componet is causing the lack of performance – Michael Hidalgo Aug 24 '11 at 19:32
  • @Michael: Most likely not. Try using WCF client proxy. – Dmitry Aug 24 '11 at 19:39
  • Actually I need to work with ws-* compliant, for that reason I'm using WebService reference feature not Add Service reference – Michael Hidalgo Aug 24 '11 at 19:52
  • @Michael: WS-* what exactly? WS-Security for example is supported by WCF. – Dmitry Aug 24 '11 at 19:59
  • I think I found where the problem is. This service has almost 250 webmehods and each methods use a lot of clases.It appears that the reference deserialize each object used by the method is being deserialized. I did a test using StopWatch class and the first time the reference takes 34 seconds. I commented all this serialization mechanism and it improved to 6 seconds. Fortunately I just need few web methods from that service :) – Michael Hidalgo Aug 24 '11 at 20:45