You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Andreas Leitner <no...@sbox.tugraz.at> on 2002/08/09 15:11:56 UTC

Attachment problem

Hi,

I am trying to implement a minimum Attachment example, but it does not seem to work. I give details below, but the error I get is:

--
Tried to invoke method public void at.macron.helloWorldServer.Server.addImage(javax.activation.DataHandler) with arguments org.apache.axis.attachments.AttachmentPart.  The arguments do not match the signature.
--

Which means that the client does not correctly specify my DataHandler as a DataHandler.


Here is the Server
--
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.net.URL;
import javax.activation.DataHandler;
import java.util.LinkedList;
import java.util.List;
import java.io.BufferedInputStream;

public class Server
{
    public Server ()
    {
    }

    public void addImage (DataHandler dh)
    {
    }
}
--
And the client

--
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;

import java.net.URL;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.XMLType;

import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import org.apache.axis.encoding.ser.*;
import javax.activation.FileDataSource;
import javax.activation.DataHandler;

public class AttachmentTest
{

    public static void main (String [] argv) 
    {
        try 
        {
            DataHandler dh = new DataHandler (new FileDataSource ("/tmp/foo.txt"));
            String endpointURL = "http://excelsior:12016/axis/services/vip";
            String methodName = "addImage";
            Service service = new Service ();
            Call call = (Call) service.createCall ();
            call.setTargetEndpointAddress (new java.net.URL (endpointURL));
            call.setOperationName (new QName ("vip", methodName));
            QName qname = new QName ("vip", "DataHandler");
            call.addParameter ("dh", qname, ParameterMode.IN);
            call.registerTypeMapping (dh.getClass (), qname, 
                                      JAFDataHandlerSerializerFactory.class, 
                                      JAFDataHandlerDeserializerFactory.class);
            call.setReturnType(XMLType.AXIS_VOID);
            Object[] params = new Object[] {dh};
            call.invoke (params);
        }
        catch (Exception e)
        {
            System.out.println (e.toString ());
            e.printStackTrace ();
        }
    }


}
--


Now, tracing the SOAP Calls:
--
Listen Port: 12016
Target Host: localhost
Target Port: 11016
==== Request ====
POST /axis/services/vip HTTP/1.0

Host: localhost

Content-Type: multipart/related; type="text/xml"; start="<89...@excelsior.macron.at>"; 	boundary="----=_Part_0_3782542.1028898160244"SOAPAction: ""Content-Length: 939------=_Part_0_3782542.1028898160244Content-Type: text/xml; charset=UTF-8Content-Transfer-Encoding: binaryContent-Id: 
   <89...@excelsior.macron.at>
      <?xml version="1.0" encoding="UTF-8"?>
         <soapenv:Envelope soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> 
            <soapenv:Body>  
               <ns1:addImage xmlns:ns1="vip">   
                  <dh href="cid:317067483.1028898160174.AXIS@excelsior.macron.at"/>  
               </ns1:addImage> 
            </soapenv:Body>
         </soapenv:Envelope>------=_Part_0_3782542.1028898160244Content-Type: text/plainContent-Transfer-Encoding: binaryContent-Id: 
         <31...@excelsior.macron.at>hello this is foo.next linelast line------=_Part_0_3782542.1028898160244--
==== Response ====
HTTP/1.1 500 Internal Server Error

Content-Type: text/xml; charset=utf-8

Date: Fri, 09 Aug 2002 13:02:41 GMT

Server: Apache Tomcat/4.0.3 (HTTP/1.1 Connector)

Connection: close



<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
      <soapenv:Body>  
         <soapenv:Fault>   
            <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.generalException</faultcode>   
            <faultstring>Tried to invoke method public void at.macron.helloWorldServer.Server.addImage(javax.activation.DataHandler) with arguments org.apache.axis.attachments.AttachmentPart.  The arguments do not match the signature.</faultstring>  
         </soapenv:Fault> 
      </soapenv:Body>
   </soapenv:Envelope>
--

Does anybody know what could be wrong?


tia,
Andreas