SocketTimeoutException when running attachment scenario.
--------------------------------------------------------

         Key: AXIS2-834
         URL: http://issues.apache.org/jira/browse/AXIS2-834
     Project: Apache Axis 2.0 (Axis2)
        Type: Test

  Components: transports  
    Versions: 1.0    
 Environment: WIN OS
    Reporter: Samuel Isokpunwu


I created a service class that will provide an image when given an image type 
and a client that request for a given image type.
This test scenario is basically a reverse of one of the MTOM testcases, in the 
sample package, to get an image instead of sending an image.
The service deployment was successful and I can trace the call up to the 
service operation which successfully creates the response OMElement with the 
requested image but I repeatedly get a timeout before the service response gets 
to the client.

Could someone help review the test cases below and perhaps suggest what I may 
have done wrong in the implementations. 

My service impl method is this:

    public OMElement imageDepot(OMElement element) throws Exception {
        OMElement omeRequest = null;
        
        for (Iterator iterator = element.getChildElements(); 
iterator.hasNext();) {
                          OMElement ome = (OMElement) iterator.next();
                          if (ome.getLocalName().equalsIgnoreCase("request")) {
                              omeRequest = ome;
                          }
                     }
        
        if (omeRequest == null ) {
                         throw new AxisFault("Client request OMElement is 
null");
                     }
        
        if(omeRequest.getText().equalsIgnoreCase("jpeg")){
            DataHandler expectedDH;
                         OMFactory fac = OMAbstractFactory.getOMFactory();
                         OMNamespace omNs = 
fac.createOMNamespace("urn://fakenamespace", "ns");
     
                         OMElement data = fac.createOMElement("response", omNs);
                         OMElement image = fac.createOMElement("image", omNs);
                         Image expectedImage = new ImageIO().loadImage(new 
FileInputStream(new File("D:\\dev\\image\\test.jpg")));
                         ImageDataSource dataSource = new 
ImageDataSource("test.jpg",expectedImage);
                         expectedDH = new DataHandler(dataSource);
                         OMText textData = fac.createOMText(expectedDH, true);

                         image.addChild(textData);
                         data.addChild(image);
                         return data;           
        }

The client implementation is this:

public void testGetImage() throws Exception{
     OMElement result = getImage("jpeg");
     OMElement omeImage = null;
      for (Iterator _iterator = result.getChildElements(); 
_iterator.hasNext();) {
            OMElement ome = (OMElement) _iterator.next();
            if (ome.getLocalName().equalsIgnoreCase("image")) {
                   omeImage = ome;
            }
        }
                
      if (omeImage == null ) {
            throw new AxisFault("Image element content is null");
      }
                
      //Extract the image content and save it the data and saving
      OMText imageReceived = (OMText) omeImage.getFirstOMChild();
      DataHandler dh = (DataHandler) imageReceived.getDataHandler();
      Image image = new 
ImageIO().loadImage(dh.getDataSource().getInputStream());
      FileOutputStream imageFOS = new FileOutputStream(ClientOutputFileName);
      new ImageIO().saveImage(dh.getContentType(), image, imageFOS);
                
      if(dh.getContentType().equalsIgnoreCase("image/jpeg")){
          System.out.println("SUCESS");
}
        
public OMElement getImage(String imageType) throws Exception {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace ns = fac.createOMNamespace("http://localhost/my";, "my");
        
        OMElement operation = fac.createOMElement("imageDepot", ns);
        
        OMElement request = fac.createOMElement("request", ns);
        request.setText(imageType);
        
        operation.addChild(request);
        
        Options options = new Options();
        options.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        options.setTo(targetEPRName);
        options.setProperty(Constants.Configuration.ENABLE_MTOM, 
Constants.VALUE_FALSE);
        options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

        ServiceClient sender = new ServiceClient();
        sender.setOptions(options);
        return sender.sendReceive(operation);
}

The deployed service.xml is this:

<service name="MTOMService">
    <description>
        This is a sample Web Service for illustrating MTOM based binary data 
transfer.
    </description>
    <parameter name="ServiceClass" 
locked="false">sample.mtom.imagetransfer.service.MTOMService</parameter>
    <operation name="imageDepot">
        <actionMapping>urn:imageDepot</actionMapping>
        <messageReceiver 
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </operation>
</service>

I continue to get the following socket timeout exception.

org.apache.axis2.AxisFault: Read timed out; nested exception is: 
        java.net.SocketTimeoutException: Read timed out; nested exception is: 
        org.apache.axis2.AxisFault: Read timed out; nested exception is: 
        java.net.SocketTimeoutException: Read timed out
        at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java)
        at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java)
        at 
org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java)
        at 
org.apache.axis2.description.OutInAxisOperationClient.execute(OutInAxisOperation.java)
        at 
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:451)
        at 
org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:393)
        at com.ibm.attachment.tc.mtom.MTOMTest.getImage(MTOMTest.java:98)
        at com.ibm.attachment.tc.mtom.MTOMTest.testGetImage(MTOMTest.java)
        at com.ibm.attachment.tc.mtom.MTOMTest.main(MTOMTest.java)
Caused by: org.apache.axis2.AxisFault: Read timed out; nested exception is: 
        java.net.SocketTimeoutException: Read timed out
        at 
org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java)
        ... 9 more
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:155)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:229)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:246)
        at 
org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)
        at 
org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)
        at 
org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115)
        at 
org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)
        at 
org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)
        at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
        at 
org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:636)
        at 
org.apache.axis2.transport.http.SOAPOverHTTPSender.send(SOAPOverHTTPSender.java:116)
        ... 10 more


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to