Solved

Calling WCF Service from Java -- Connection reset exceptions

Posted on 2013-01-31
6
2,106 Views
Last Modified: 2013-02-06
Hello All,

A Java application is calling my WCF service.  Once in a while they get the follow exception:


Connection reset; nested exception is java.net.SocketException: Connection resetorg.springframework.ws.client.WebServiceIOException: I/O error: Connection reset; nested exception is java.net.SocketException: Connection reset
      at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:543)
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:384)
      at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:378)




This is the Java code being used to call the WCF Service:




public <T> T sendAndReceive(String uriString,
                                 WebServiceMessageCallback requestCallback,
                                 WebServiceMessageExtractor<T> responseExtractor) {
        Assert.notNull(responseExtractor, "'responseExtractor' must not be null");
        Assert.hasLength(uriString, "'uri' must not be empty");
        TransportContext previousTransportContext = TransportContextHolder.getTransportContext();
        WebServiceConnection connection = null;
        try {
            connection = createConnection(URI.create(uriString));
            TransportContextHolder.setTransportContext(new DefaultTransportContext(connection));
            MessageContext messageContext = new DefaultMessageContext(getMessageFactory());

            return doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
        }
        catch (TransportException ex) {
            throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex);
        }
        catch (IOException ex) {
            throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex);
        }
        finally {
            TransportUtils.closeConnection(connection);
            TransportContextHolder.setTransportContext(previousTransportContext);
}


Any ideas?
0
Comment
Question by:smokinmark
  • 4
  • 2
6 Comments
 
LVL 26

Expert Comment

by:dpearson
ID: 38842847
A connection reset exception generally just means the connection has been closed.

If this call is being placed over the internet this may simply be a network connection failure - somebody dropped the data along the chain between your servers.

However if the call is over a LAN you can probably assume the connection is reliable, in which case you should look for an error that's causing the communication to not complete - e.g. an exception being thrown part way through the message sending, which then prematurely causes the client to close the connection (or socket).

Doug
0
 

Author Comment

by:smokinmark
ID: 38843755
Would you be willing to look at my web.config file for the WCF service?
0
 
LVL 26

Expert Comment

by:dpearson
ID: 38844545
Sorry - I'm not familiar with WCFs.  I've just seen those exceptions a thousand times in writing network services that operate over the web.

Doug
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:smokinmark
ID: 38844557
I'm beginning to wonder if this is an IIS thing.

I have traced this further in the Windows Event Logs.  

"A process serving application pool 'XXX' suffered a fatal communication error with the Windows Process Activation Service. The process id was '1234'. The data field contains the error number."
0
 

Accepted Solution

by:
smokinmark earned 0 total points
ID: 38845731
Turns out this was a Red Herring.  Problem is elsewhere.  Will make a separate post.  Thanks a million.
0
 

Author Closing Comment

by:smokinmark
ID: 38858747
As posted by me.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tomcat startup error 5 59
Simple Injector with Web Service 4 38
Reading the web config for a running service on Windows 10 16 40
Store results in vb.net 3 20
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now