I have a WCF service (.NET 4) hosted in IIS. My service contract has one method with:
[FaultContract(typeof(string))]
My service implementation for that method validates input parameters and may throw an exception like this:
if (string.IsNullOrWhiteSpace(siteName)) { throw new FaultException("siteName is required."); }
The consumer program of this service is a .NET 2 console application. In this app I generated the webservice proxy by right clicking "References" and "Add web reference".
When I try to call the service method from the client app, by sending an invalid siteName, I get back a 503 Service Unavailable exception, instead of a FaultException with the custom error message.
How can I make the FaultException, with the custom error message, propagate to the client program?
UPDATE:
The exception I get in the client application is this:
System.ServiceModel.ServerTooBusyException:
The HTTP service located at
http://www.example.com/services/myservice.svc
is too busy. ---> System.Net.Web
Exception: The remote server returned
an error: (503) Server Unavailable.
at
System.Net.HttpWebRequest.GetResponse()
at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpCha
nnelRequest.WaitForReply(TimeSpan
timeout) --- End of inner exception
stack trace ---
The problem was being caused by a custom HTTP module in our web project. So it was not exactly a WCF problem, but a problem specific to our solution. Thanks!
Related
So currently I managed to reach an existant Web Service and use one of it's functions to alter a database.
However, the Web Service does not respond with a Soap Response, but with just the HTTP Respond Code 200, which I want to use to create a "Success!"-like notification.
Using BusinessWorks I was able to to connect the process with a HTTP Receiver in the Modeler-View, but it doesn't work and gives me the error message
"Process configuration error. The activity [HTTPReceiver] in the process [webservices.module.IWSContract] cannot have an input transition."
My goal is to catch the HTTP Response Code 200 from the Web Service, and optionally display it to the user.
As you mention you use TIBCO BW 6. this should be the "Invoke" activity instead of SOAPRequestreply (Basic Palette -> Invoke)
You need to use a SOAP Request-Reply activity to invoke the web service. Technically, the "HTTP 200" response won't be visible but you will get an empty output in case of a success:
You can then choose to return whatever success message to the user.
I'm trying the consume a web services built using Axis2, so I have followed this example for creating client code.
I have the endpoint and I'm able to access it through the browser. But trying to generate the client code with:
WSDL2Java.bat -uri <<endpoint>> -o client
throws the exception below:
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: Error parsing WSDL
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:181)
at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:141)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:411)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:525)
at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:272)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:923)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.(CodeGenerationEngine.java:99)
... 2 more
What could be the reason for this error?
If you can access the WSDL from a browser but not from the tool in command line then it's possible that your browser uses a HTTP proxy for it's connection while wsdl2java goes straight for the address.
Try setting some JVM parameters for using a proxy, as described in Java Networking and Proxies and if that fails, there is always the option to download the WSDL with the browser and run wsdl2java with the locally downloaded file.
I am developing a wp7 app that consumes a simple web service written in asp.net
The web service is working fine in desktop application (written in c#) (also tested in web browser and is working fine) but it is not working in wp7.
Following is the code I am using in wp7 to call the webservice
BookService.BooklocationSoapClient client = new BookService.BooklocationSoapClient();
client.BookListCompleted += new EventHandler<BookService.BookListCompletedEventArgs>(client_BookListCompleted);
client.BookListAsync(dId);
void client_BookListCompleted(object sender, BookService.BookListCompletedEventArgs e)
{
Debug.WriteLine(e.Result);
}
and following is the exception I am getting
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
A first chance exception of type 'System.ServiceModel.FaultException' occurred in System.ServiceModel.dll
Also, I am getting the following message
Server was unable to process request. ---> Length cannot be less than zero.
Parameter name: length
Seems like you try to call local web service on your developer machine, which not allowed by
windows phone emulator.
Try call any public web service available in internet, as example weather forecast
PT 8.50.15
We have a new integration with a third party system. They have provided the wsdl and I have used the consume web service wizard to consume it into PeopleSoft. All this does is give you the stub messages with a schema attached to each. I have written some peoplecode to send a test message out to the webservice. When the webservice returns a valid result, I have no problems. However, when the webservice returns a fault message, I get the following error:
Integration Gateway - HttpTargetConnector:ExternalApplicationException. Http status code HttpStatusCode returned : 500. (158,10623)
HttpTargetConnector:ExternalApplicationException. External System responded with an Error status. For Http Status Code explanation please check Http protocol Specifications.
I know the webservice is returning the fault message b/c I have tried the same thing in SOAPUI. Does anyone know why PeopleSoft throws up this error ONLY on the fault message?
In addition to the prior response, the 500 error you are seeing should be followed by any soap fault coming back with the response in the errorLog.html file on your gateway (or msgLog depending on the ig.log.level setting in your integrationgateway.properties file. Check the 'response' section, as well as the stack trace for additional information.
On the routing that you are using, click the 'User Exception' check box. Then you will not get the HTTP 500 error. Evaluate the response from the response message. If it's not zero, you will then be able to parse the SOAP fault and see what the returned faultstring is.
Get your Service operation corrected. I Had same issue, After i changed the SO in this code it started working
&msgRequest = CreateMessage(Operation.Operation_name, %IntBroker_Request);
I am having an issue with the SOAP , when I call my services I get this error:
<faultstring>Fault occurred while processing.</faultstring>
The following response is returned which doesn't give a clue where and why the error happens. How can I customize and show a proper detailed message to user so he/she know what they did wrong
I have gone through the CXF customization with outFaultInterceptors and inFaultInterceptors but I am not clear how I am gonna customize cxf.
This means that the web service framework is returning an unchecked exception. Try running the web service on a debugger to see where the exception is happening or wrapping the web service body inside an try/catch to print the stack trace.