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 Mohanbabu Narayanasamy <mx...@bjc.org> on 2007/01/11 20:54:43 UTC

setting content-id for DIME attachment

Hello,
 
I'm integrating axis 1.3 client with a .NET web service - receiving and sending JPEG images as DIME attachments. 
 
I'm able to receive JPEG images, but I'm having issues sending them. I'm using the DIME encapsulation format and setting all headers correctly. The .NET webservice is able to receive the request. It reads the XML part of the message correctly but is unable to read the JPEG image (I have verified this on the server side). I think it's an issue with the content-id I set in each item of the SOAP request.  
 
I have to set the content-id in the XML message (as string) I send in. I also set the content-id in the HTTP header. This content-id in the XML part is used by .NET webservice to read that content.
 
The issue is SOAP generates its own content-id for the image and sends it to .NET service; this content-id is different than the one I set in the XML...so the server code errors out.
 
I need to get the content-id which SOAP generates and set it in the XML request. How do I do this?
 
this is my client code:
 
 public SendSaveBatchResponse sendBatch(Request request)
{
 
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[9]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("<uri>");
        _call.setEncodingStyle(Call.ENCODINGSTYLE_URI_PROPERTY);
        _call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
        _call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("<service>", "<operation>"));
        _call.setProperty(Call.ATTACHMENT_ENCAPSULATION_FORMAT,
                        Call.ATTACHMENT_ENCAPSULATION_FORMAT_DIME);
        String contentid =  Request.getBatch().getDocuments().getDocument(0).getPages().getPage(0).getID(); //get content-id from the page-id property which is in XML schema
 
         Hashtable<String, String> chunkedTable = new Hashtable();
         chunkedTable.put(HTTPConstants.HEADER_CONTENT_ID, contentid); //set the content-id in the HTTP header
        chunkedTable.put(HTTPConstants.HEADER_ACCEPT, HTTPConstants.HEADER_ACCEPT_APPL_SOAP);
        chunkedTable.put(HTTPConstants.HEADER_ACCEPT, HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME);
        chunkedTable.put(HTTPConstants.HEADER_ACCEPT, HTTPConstants.HEADER_ACCEPT_ENCODING);
        chunkedTable.put(HTTPConstants.HEADER_ACCEPT, HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED);
        chunkedTable.put(HTTPConstants.HEADER_ACCEPT, HTTPConstants.HEADER_ACCEPT_TEXT_ALL);
        chunkedTable.put(HTTPConstants.HEADER_CONTENT_TYPE, HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME);
        
        _call.setProperty(MessageContext.HTTP_TRANSPORT_VERSION, HTTPConstants.HEADER_PROTOCOL_V11);
        _call.setProperty(HTTPConstants.REQUEST_HEADERS, chunkedTable);
        
          DataHandler handler = request.getHandler(); // get the JPEG data; handler already has the jpeg data in it
  
         addAttachment(handler);
         setAttachments(_call);
         try {
                 java.lang.Object _resp = _call.invoke(new java.lang.Object[] {sendBatchRequest});
        } catch (org.apache.axis.AxisFault axisFaultException) {
                    throw axisFaultException;
       }
 
I used TcpMon to trace SOAP messages; I get this SOAP header:
 
POST /services/service.asmx HTTP/1.1
Content-Type: application/dime
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.3
Host: <host> :8000
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "<soap action>"
Content-Length: 107596
Connection: close
Accept: text/*
Content-Id: 714C6C40-4531-442E-A498-3AC614200295 //this is the id I want to set
Content-Type: application/dime
Note that the content-id is set is same as that of XML value I set
 
The message has two parts: the xml and the image
 
now comes the XML part of the request. The UUID is same as that of HTTP content-id:
 
uuid: 714C6C40-4531-442E-A498-3AC614200295
 
*--XML message here--
 
<?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"><ns3:SendBatchRequest><ns2:SendBatch><soapenv:Body ( 'http://www.w3.org/2001/XMLSchema-instance" )>
<ns3:handler ="7C277702D16977173AF773F0C59EDF4E"/></ns3:SendBatchRequest></ns2:SendBatch></soapenv:Body></soapenv:Envelope>
 
 
Note the XML has the content-id of the image <ns3:handler href="7C277702D16977173AF773F0C59EDF4E"/> in this xml
 
and then the binary data . the binary data begins with the content-id ="7C277702D16977173AF773F0C59EDF4E"
 
*--Binary message here--
 
7C277702D16977173AF773F0C59EDF4E image/jpeg <binary data here>
 
 
----end message----
 
How do I get the href value (the ="7C277702D16977173AF773F0C59EDF4E" part) which is set in the XML part in the java code? 
 
please feel free to correct me if I'm doing anything wrong.
 
thanks
Babu