Web Service Sending Base64Binary data

kate

New Member
I have a webservice that is expecting a binary data in the form Base64Binary, its basically a pdf file that i need to send. The service is not expecting MTOM or SOAP attachment. It wants data in this format.I tried converting the byte to Base64Binary form but i see my request sending a empty tag for message.\[code\]public Base64Binary createBinaryData() { Base64Binary base64Binary = new Base64Binary(); try { File file = new File("C:/NetBeans/files/test.txt"); byte[] bytes = loadFile(file, new ByteArrayOutputStream()).toByteArray(); base64Binary.setValue(bytes); } catch (IOException ex) { System.out.println(ex); } System.out.println("Binary data Size" + base64Binary.getValue()); return base64Binary; } private static <T extends OutputStream> T loadFile(File file, T out) throws IOException { FileChannel in = new FileInputStream(file).getChannel(); try { assert in.size() == in.transferTo(0, in.size(), Channels.newChannel(out)); System.out.println("Size " + in.size()); return out; } finally { in.close(); } }\[/code\]and this is the request message that is getting generated\[code\]<?xml version='1.0' encoding='UTF-8'?> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns2:sendRightFaxEIARequest xmlns="http://svc.kp.org/diag_thrpy/phrmcy/RightFaxEIAErrorTypes/v1" xmlns:ns2="http://svc.kp.org/eps/RightFaxEIATypes/v1" xmlns:xmime="http://www.w3.org/2005/05/xmlmime"> <ns2:Message> <ns2:Header> <ns2:From>Amar</ns2:From> </ns2:Header> <ns2:Body> <ns2:EIARequest> <ns2:Pharmacy>Test Pharmacy</ns2:Pharmacy> <ns2:EIAAttachment> <ns2:fileName>Test</ns2:fileName> <ns2:binaryData></ns2:binaryData> <ns2:checksumAlgorithm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> </ns2:EIAAttachment> </ns2:EIARequest> </ns2:Body> </ns2:Message> </ns2:sendRightFaxEIARequest> </S:Body> </S:Envelope>\[/code\]Does anyone have any idea what i could be missing.Here is the snap shot of the xsd \[code\]<xs:complexType name="EIAAttachmentType"> <xs:sequence> <xs:element name="fileName" type="xs:string" nillable="true" minOccurs="0"/> <xs:element name="binaryData" type="xmime:base64Binary"/> <xs:element name="checksum" type="xs:string" minOccurs="0"/> <xs:element name="checksumAlgorithm" nillable="true" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="http://stackoverflow.com/questions/13735356/MD5|CRC32|CRC64|SHA"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType>package org.kp;import javax.xml.bind.annotation.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlType;/** * <p>Java class for EIAAttachmentType complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * <complexType name="EIAAttachmentType"> * <complexContent> * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * <sequence> * <element name="fileName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="binaryData" type="{http://www.w3.org/2005/05/xmlmime}base64Binary"/> * <element name="checksum" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * <element name="checksumAlgorithm" minOccurs="0"> * <simpleType> * <restriction base="{http://www.w3.org/2001/XMLSchema}string"> * <pattern value="http://stackoverflow.com/questions/13735356/MD5|CRC32|CRC64|SHA"/> * </restriction> * </simpleType> * </element> * </sequence> * </restriction> * </complexContent> * </complexType> * </pre> * * */@XmlAccessorType(XmlAccessType.FIELD)@XmlType(name = "EIAAttachmentType", propOrder = { "fileName", "binaryData", "checksum", "checksumAlgorithm"})public class EIAAttachmentType { @XmlElement(nillable = true) protected String fileName; @XmlElement(required = true) protected Base64Binary binaryData; protected String checksum; @XmlElement(nillable = true) protected String checksumAlgorithm; /** * Gets the value of the fileName property. * * @return * possible object is * {@link String } * */ public String getFileName() { return fileName; } /** * Sets the value of the fileName property. * * @param value * allowed object is * {@link String } * */ public void setFileName(String value) { this.fileName = value; } /** * Gets the value of the binaryData property. * * @return * possible object is * {@link Base64Binary } * */ public Base64Binary getBinaryData() { return binaryData; } /** * Sets the value of the binaryData property. * * @param value * allowed object is * {@link Base64Binary } * */ public void setBinaryData(Base64Binary value) { this.binaryData = http://stackoverflow.com/questions/13735356/value; } /** * Gets the value of the checksum property. * * @return * possible object is * {@link String } * */ public String getChecksum() { return checksum; } /** * Sets the value of the checksum property. * * @param value * allowed object is * {@link String } * */ public void setChecksum(String value) { this.checksum = value; } /** * Gets the value of the checksumAlgorithm property. * * @return * possible object is * {@link String } * */ public String getChecksumAlgorithm() { return checksumAlgorithm; } /** * Sets the value of the checksumAlgorithm property. * * @param value * allowed object is * {@link String } * */ public void setChecksumAlgorithm(String value) { this.checksumAlgorithm = value; }}\[/code\]
 
Back
Top