There are lots of similar questions on StackOverflow. If this is a duplicate, I would appreciate a little explanation of how to apply other solution in my context please.
I have a project that is a WebAPI. This WebAPI in turn calls a web service (WSDL), processes the data and returns to the client:
[Client] ----> [My WebAPI] ----> [WSDL Server]
|
<-------- [My WebAPI] <---------
The WSDL part is a Java-based service. The only way we could consume it without issue in VS2015 was to add it as a Web Reference (2.0 in the dialog). It works perfectly, with strongly-typed values as required, but today we've seen a timeout between My WebApi and WSDL Server.
In other answers on SO, I see that the timeout period can be configured in web.config <bindings> or via a proxy, but I can't see how to wire this up given my web.config contents, which differs massively from other peoples. The code below was generated by VS2015 when the WSDL service was consumed:
<system.serviceModel>
<bindings />
<client />
</system.serviceModel>
<applicationSettings>
<MyWebAPI.Properties.Settings>
<setting name="MyWebAPIs_ThirdPartyWSDLService_GetData" serializeAs="String">
<value>https://wsdl.domain.com/webservices/services/GetData</value>
</setting>
</MyWebAPIs.Properties.Settings>
</applicationSettings>
I also can't find any mention of timeouts in the c# intellisense code. Any help or pointers would be appreciated. I've read about 12 posts on SO but still can't figure it out.
I hate to answer my own question but I think I've found the answer (I will remove if not). This is obvious, but reading too much on SO actually threw me off course and I was inspecting the wrong class in VS.
When consumed, the third-party web service client class GetData() is forced to derive from SoapHttpClientProtocol. This class derives from HttpWebClientProtocol, derived from WebClientProtocol.
WebClientProtocol has a public property Timeout, expressed in milliseconds.
Indicates the time an XML Web service client waits for the reply to a synchronous XML Web service request to arrive (in milliseconds).
The time out, in milliseconds, for synchronous calls to the XML Web service. The default is 100000 milliseconds.
Setting the Timeout property to Timeout.Infinite indicates that the request does not time out. Even though an XML Web service client can set the Timeout property to not time out, the Web server can still cause the request to time out on the server side.
Therefore the Timeout property is available directly from code when instantiated as a web service client, which I believe is due to the magic of VS:
SomeComsumedWebService wsc = new SomeComsumedWebService();
SomeComsumedWebService.Timeout = 600000; // 10 minutes
var obj = SomeComsumedWebService.MethodToGetData();
Related
I´m trying to create a client in C# to a web service which (I suppose) is written in Java. It´s my first time trying to write a client, so I´m following the instructions on MSDN, but I´m stuck on a problem with Add Reference. When I open the Add Service Reference dialog and add the URL, an error occurs:
There was an error downloading 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://geoportal.cuzk.cz/WCTService/WCTService.svc'.
There was no endpoint listening at http://geoportal.cuzk.cz/WCTService/WCTService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
What should my next step be? I don´t know what I should do with this!
(It is a coordinates-transformation service from the Czech Republic.)
For more information:
Property services (GetCapabilities)
http://geoportal.cuzk.cz/WCTService/WCTService.svc/get?
Localization services:
http://geoportal.cuzk.cz/WCTService/WCTService.svc/get?request=GetCapabilities&service=WCTS
I was facing a similar situation in which I had created a WCF Service (Employee.svc) and later changed the named to EmployeeService.svc. WCF project compiled just fine but when I was trying to add service reference from by UI Client, I was getting following error:
Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc?wsdl'.
The document format is not recognized (the content type is 'text/html; charset=UTF-8').
Metadata contains a reference that cannot be resolved: 'http://localhost:2278/EmployeeService.svc'.
There was no endpoint listening at 'http://localhost:2278/EmployeeService.svc' that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
I resolved it by replacing the correct service class name everywhere. In my case, it should have been EmployeeService and NOT employee. The left out place was in the markup code of svc file:
<%# ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**Employee**" CodeBehind="EmployeeService.svc.cs" %>
Changed it to
<%# ServiceHost Language="C#" Debug="true" Service="WCFServiceHost.**EmployeeService**" CodeBehind="EmployeeService.svc.cs" %>
And it started working again!!! Dont forget to build your WCF project after changing the service name.
I tried browsing to http://geoportal.cuzk.cz/WCTService/WCTService.svc?wsdl. It looks like this service is not exposing metadata.
I did a bit of googling on OpenGIS, and I think you need to have a look at this article:
OpenGIS with .NET
You won't be able to just add a service reference and go. It looks like you need to craft a concrete WSDL.
There may be a client-side library you can use / customize to assist with integration. Have a look at Stack Overflow question Using MySQL GeoSpatial data types in .NET.
I know this is an old thread and has already been resolved, but I just finished troubleshooting this exact issue, and none of the resolutions presented here worked for me. Wanted to share my resolution in case anyone else runs into this thread with a similar issue.
My ENTIRE issue stemmed from a bad Refactor->Rename operation. I recently purchased Resharper for my dev team and Resharper did not like the name of our service implementation name. We had named it "WCFAccess" and Resharper wanted the name "WcfAccess". I had just published an update, had the release safely isolated in its own release branch in git, and figured this was a good time to perform a rename on the develop branch and shut Resharper up about the naming. I used Refactor->Rename to change the name of the file to match the naming convention we had defined in the Resharper configuration. The rename operation completed, the solution compiled and ran, time goes on and the WCF rename was forgotten.
Fast forward a couple weeks, and its time to deploy out web services to the test environment for regression testing. The solution compiled successfully, published successfully, then gave me the EXACT error that the OP posted. What I ended up finding out is that the Rename operation from weeks ago ONLY UPDATED SOURCE CODE REFERENCES to the old name and did not rename MARKUP. When I navigated out to our web server where the service was published to and double clicked on the .svc file, it opened the markup in Visual Studio and I noticed that the character casing of the CodeBehind="ServiceNameHere.svc.vb" was inconstant with the new naming convention. Updating the markup and web.config files to reference the correct character casing resolved my issue.
I hope this helps someone. It was incredibly frustrating to troubleshoot
(Please don't hate me for using VB.Net, I inherited this application) :-)
Is the service definitely up and running before you try to add a service reference? If it exposes meta data, does it have a service behaviour or equivalent configured? Have you configured your firewall correctly?
While adding service reference to the client application, metadata is not accessible from service to client application. hence The remote server returned an error: (404) Not Found. Actually we can host the WCF service as follows:
Self hosting(console application)
IIS Hosting
WAS Hosting
window service hosting.
if you are using self hosting then you need to host the service in console application and run the service(run the console application) and then add the service reference to the client application, then metadata would be exchange. If service is not running then while adding service reference to the client application then 404 not found error would be getting. Same process would follow for all the hosting type. first run the service then add service reference.
I had the same problem happen to me earlier today. The webservice was running fine on local host but for some reason, I was having a 400 when trying to add the service reference in another project.
My error was caused by setting the [DataMember] annotation instead of the [EnumMember] annotation on an enum of the service. Changing it solved my issue.
The webservices doesn't run.
If you don't have access to the server where this service run, you're blocked.
Otherwise, you need to check if the server run, etc. As I don't know how the Java webservice is run, I can't help you further.
I have a WCF Webservice hosted on IIS which exposes a single method that takes three integer parameters. I have a simple, console based client which can call this method.
int InsertNewOrder(short quantity, int custID, int productID);
If my understanding is correct, I need to provide JMeter a SOAP envelope with the details of the method to be called and parameters to be passed. I have seen many examples similar to below:
<soapenv:Envelope xmlns:soapenv="schemas.xmlsoap.org/soap/envelope/">;
<soapenv:Body>
<ns2:InsertNewOrder xmlns:ns2="?????">
<ns2:Param1>${1}</ns2:Param1>
<ns2:Param1>${1}</ns2:Param1>
<ns2:Param1>${1}</ns2:Param1>
</ns2:InsertNewOrder>
</soapenv:Body>
</soapenv:Envelope>
However, from looking at my WSDL doc, I don't see where it refers to any of the parameters needed to pass to the method. I've also used Fiddler to examine the client's soap messages to the service. Again, I don't see where it's passing the parameters. As a result, I don't know how to create a simple SOAP envelope I can use with JMeter to test this service.
Can anyone advise as to why the WSDL doc does not provide any details of the method parameters, or explain how I can create the necessary SOAP envelope for use with JMeter?
I am coding in C# using VS 2010, JMeter 2.4, IIS v6, wsHttpBinding.
Disclaimer: I'm not a WSDL expert, so i can't tell you why the doc doesn't provide detail.
To generate the SOAP envelope for JMeter, I've used the free version of soapUI.
Steps
Import WSDL into soap
Create a default request for the method
Set the request view to RAW, and copy into JMeter
This provides me all the information I need for jmeter, including parameters, user-agent, endpoint, etc.
Use JMeter's "HTTP Proxy Server" to record the WCF calls with your normal testclient, and then play them back later when testing. This is what I have experienced to be fastest, and gives the best test-cases (because you record them with your normal client, or test client of choice).
Set up JMeters HTTP Proxy Server as per instructions. Then, make sure the WCF (or any SOAP) client use that proxy. The important part of the WCF client configuation is (replace my ... with normal config):
<system.serviceModel>
<bindings>
...
<wsHttpBinding>
<binding ... proxyAddress="http://proxyServerName:8080" useDefaultWebProxy="false" ...>
...
<security mode="None">
<message establishSecurityContext="false"/>
<transport clientCredentialType="None"/>
</security>
proxyServerName is localhost, if the WCF client runs on the same machine as JMeter (normal when creating the test cases).
Also, I got an error message using HTTP Proxy, if I did not turn off security as shown above. The same security settings must also be at the WCF service server.
Happy testing! :-)
Background
I am developing an ASP.Net server side control that needs to talk to an ASMX web service. The server side control uses a WebClient object to talk to the web service, since it needs to be reused often in various application, and to make it easier on the developers, they are not required to create a service reference to the web service.
Implementation
During the use of the control, it is requires the sending of a serialised object to the web service. The object is serialised using the XmlSerializer and the resulting XML string is then compressed using the chilkat compression library. The web service call for the control looks as follows:
webClient.UploadStringAsync(new Uri(serviceHost + serviceMethod), "POST", sendData)
The content of sendData (string) is compressedResponse={CompressedData}.
The web service has a method defined as follows to receive the data and then decompress the string value using the chilkat library before de-serialising the object using the XmlSerializer.
public void SaveResponse(string compressedResponse)
The communication between the control and the service is working. Initially there were no settings or binding defined in the web.config for any of the above. After initial searching I did add
<httpRuntime maxRequestLength="20480"/>
to both the client and server web.config files. This has made no difference.
Problem
Compressed or uncompressed the data being posted to the web service in the sendData variable is to big for a normal POST request, and is corrupted. This is confirmed when checking the last few characters of the string before and after it being posted to the server in compressed format, and uncompressed, the Xml document is missing the last root tag when checking in the debugger. The string can't be decompressed and therefore the service call fails every time.
How do I increase the POST size for the WebClient request to ensure that the full string is received by the server?
I have looked at the various option on Google, but none are giving me a good enough sample of where to make the changes, or samples of what the changes need to look like. I am completely lost as to whether the change needs to be made on the server or the consuming website, and since there are no binding defined for this, how to create a binding in the web.config for an ASMX HTTP service call.
I believe you must be hitting ASP.NET max request length limit. That you can modify via config file such as:
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
maxRequestLength value is in KB, so above setting would allow 20 MB. You can also apply the setting only to selected URLs using location tag e.g.
<location path="yourservice.asmx">
<system.web>
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
</location>
There seems to be no way to change the POST size for a ASMX Web Service when only HttpPost is enabled.
The solution in the end was to switch the service to running HttpSoap and create a service reference to the assembly containing the control. Once done the binding is created using code in the control once the endpoint is set via a property.
I'm trying to create a web service using Azure.
For the time being, everything is being run locally. The web service and Azure work fine, a simple string Test() method which returns "Hello world" works without problems, as you'd expect. ;)
Now, I've created two methods which add rows to Azure Data Tables. The first sends (using a special DataContract) a single row of data, and this works fine.
The second is for sending larger amount of data, and sends an IEnumerable. So, to test the service, I've created a client application which creates a number of random data to send. If I create up to 42 rows and send that, all goes well.
Above that, I get a 400 Bad request error.
The problem is that there's no inner message to work with (or rather, that WAS the inner message). I strongly suspect it has to do with the size of the request however.
Note, that if I put a breakpoint on the service's method, it doesn't even get that far. I've read quite a few various forum posts regarding similar issues, but those seemed to deal with ordinary WCF services, not Azure ones, and so the Web.config file doesn't contain definitions for bindings nor endpoints, which would be something I could work with.
Please help.
PS. I realise I may have posted very little information. If something else is needed, please ask, and I'll do my best to include it.
Adding the following lines to the Web.config file (under system.serviceModel) in the Azure service project (NOT the Web.config in the client application) resolved the issue:
<bindings>
<basicHttpBinding>
<!--The basicHttpBinding is used for clients which use the generated code to transmit data; the following
settings make it possible to send larger amounts to the service-->
<binding maxReceivedMessageSize="10000000" receiveTimeout="01:00:00">
<readerQuotas maxStringContentLength="10000000" />
</binding>
</basicHttpBinding>
</bindings>
I have some silverlight code that calls a WCF service which then uses the Entity Framework to access the database and return records.
Everything runs fine but ... when I replace the Entity Framework code with classic ADO.NET code I get an error:
The remote server returned an error: NotFound
When I call the ADO.NET code directly with a unit test it returns records fine so it's not a problem with the ADO.NEt code
I used fiddler and it seems to say that the service cannot be found with a "500" error.
i don't think it's anything to do with the service as the only thing I change is the technology to access the database.
Anyone know what i'm missing here?
'NotFound' is a generic error message that could mean just about anything. If you are absolutely positive that you haven't changed the service interface, then the likely candidate is an exception is being thrown from within your service. Are you sure that the collection type that contains the data you are trying to return hasn't changed, i.e. from List< OfSomthing> to List< OfSomethingElse>?
In any case, something i have found invaluable for tracking this sort of issue is the Service Trace Viewer tool from Microsoft. Read all about it right here, all it takes is some simple changes to your web.config to enable the logging.
John Papa has a great article from MSDN Magazine Data Performance and Fault Strategies in Silverlight 3 that explains this issue and offers a solution. Due to browser limitations, error code 500s aren't routed properly. His solution modifies the outgoing HttpResponse Message back to a 200 for all Silverlight 500 responses.
If you are still stuck, you may want to try making the call to the service from the machine hosting the service. IIS by default returns much more information about what might have gone wrong when the call is from the local machine. (I believe this can be changed, but don't know for sure.)
try to add
HttpWebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
to the Application startup event of the Silverlight app.
It should give you detail of what the real error is rather than NotFound. In my case, i was missing the clientaccesspolicy.xml resuired for cross domain requests.
How to: Specify Browser or Client HTTP Handling