Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to send attachment via SOAP

user10070648Jul 5 2013 — edited Jul 5 2013

Dear All,

I have to develop a web client in order to send a Text.txt file to web server. I'm using SOAP based message. In fact I'm using eclipse IDE to develop the web client. but I'm not still knowing  how it's doing.

WSDL

[code]

        <xs:element name="ReconReport">                                       <!-- Reconciliation report -->
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="login"  type="xs:string"/>          <!-- Login name for the client -->
                    <xs:element name="pass"   type="xs:string"/>          <!-- Password for the client -->
                    <xs:element name="filename"   type="xs:string"/>          <!-- Filename for the attached reconciliation report -->
                    <xs:element name="desc"   type="xs:string" minOccurs="0"/><!-- Additional description if any -->
                    <xs:element name="attachment" type="xs:base64Binary"/>    <!-- Attachment -->
                </xs:sequence>
            </xs:complexType>
        </xs:element>

[/code]

My code

[code]

public int reconReport(java.lang.String login, java.lang.String pass, java.lang.String filename, java.lang.String desc, byte[] attachment) throws java.rmi.RemoteException {
    if (super.cachedEndpoint == null) {
        throw new org.apache.axis.NoEndPointException();
    }
    org.apache.axis.client.Call _call = createCall();
    _call.setOperation(_operations[2]);
    _call.setUseSOAPAction(true);
    _call.setSOAPActionURI("urn:ReconReport");
    _call.setEncodingStyle(null);
    _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("http://paymentGateway.celcom.com", "ReconReport"));

  

  
    setRequestHeaders(_call);
    setAttachments(_call);
  

 

  
try {    java.lang.Object _resp = _call.invoke(new java.lang.Object[] {login, pass, filename, desc, null});

    String requestmsg = "Request context[PrepaidAccountQuery] : \n"

   + _call.getMessageContext().getRequestMessage()
   .getSOAPPartAsString();

    System.out.println(requestmsg);

   

if (_resp instanceof java.rmi.RemoteException) {
        throw (java.rmi.RemoteException)_resp;
    }

    else {
        extractAttachments(_call);
        try {
            return ((java.lang.Integer) _resp).intValue();
        } catch (java.lang.Exception _exception) {
            return ((java.lang.Integer) org.apache.axis.utils.JavaUtils.convert(_resp, int.class)).intValue();
        }
    }

  } catch (org.apache.axis.AxisFault axisFaultException) {

  throw axisFaultException;

}

}

[/code]

Form Result

[code]

Request context[PrepaidAccountQuery] :

<?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><ReconReport xmlns="http://paymentGateway.celcom.com"><login>123</login><pass>123</pass><filename>BSN.TXT</filename><desc>Celcom</desc><attachment xsi:nil="true"/></ReconReport></soapenv:Body></soapenv:Envelope>

[/code]

Server accepting message

[code]

--------------------------------------------------------------------------------

ReconReport

--------------------------------------------------------------------------------

POST /axis2/services/PaymentGateway HTTP/1.1

Content-Type: multipart/related; boundary="MIMEBoundary_9aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e"; type="application/xop+xml"; start="<0.8aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e@apache.org>"; start-info="application/soap+xml"; action="urn:ReconReport"

User-Agent: Axis2

Host: cel229:18080

Transfer-Encoding: chunked

689

--MIMEBoundary_9aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e

Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"

Content-Transfer-Encoding: binary

Content-ID: <0.8aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e@apache.org>

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:ReconReport xmlns:ns1="http://paymentGateway.celcom.com"><ns1:login>xxxxxxx</ns1:login><ns1:pass>xxxxxxx</ns1:pass><ns1:filename>20120213.txt</ns1:filename><ns1:desc>xxxxxxx Recon Report</ns1:desc><ns1:attachment xmlns:ns2="http://www.w3.org/2005/05/xmlmime" ns2:contentType="text/plain"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.baca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e@apache.org" /></ns1:attachment></ns1:ReconReport></soapenv:Body></soapenv:Envelope>

--MIMEBoundary_9aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e

Content-Type: text/plain

Content-Transfer-Encoding: binary

Content-ID: <1.baca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e@apache.org>

1|40637781|44084597|110|20091019141048|121|

2|77371568|44084597|120|20091019141050|126|162727|MBB|

3|66432343|44084597|130|20091019141059|56|4111111111111111|0313|123456|

101|21339684|0192234567|140|0|0|20091019141038|

102|21339685|0192234567|140|0|0|20091019145013|

103|21339686|0192234567|140|0|0|20091019146043|

104|21339687|21339686|2009101914703|

201|40637781|0135605893|1000|20091019151058|102310-ABCDEF|

202|40637781|0135605893|2000|20091019151133|102310-ABCDEF|xxxxxxxxxxxx5442|123654|

900|23482933|40637781|20091019141059|658|

801|21337384|44084597|140|20091019141040|0193456678|Y|

TOT. REC : 10

--MIMEBoundary_9aca5e2dc7e6ba2b683923292e7c1df44d8dc670242a205e--

[/code]

Please help me.

Regards

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2013
Added on Jul 5 2013
2 comments
2,186 views