public sendLargeJaxBClass(LargeJaxBClass xml, String destinationURL) {
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(destinationURL);
method.setRequestEntity(new LargeJaxBRequestEntity(xml));
client.executeMethod(method);
try
{
Unmarshaller unmarshaller = localContext.createUnmarshaller();
BufferedInputStream is = new BufferedInputStream(method.getResponseBodyAsStream());
Object responseElement = unmarshaller.unmarshal(is);
}
catch (JAXBException e) {
}
}
public sendLargeJaxBClassResteasy(LargeJaxBClass xml, String destinationURL) {
LargeJaxBClassInterface proxy =
ProxyFactory.create(LargeJaxBClassInterface.class, destinationURL);
MyResponseType response = proxy.storeData(params);
}
public interface LargeJaxBClassInterface {
@POST
@Path("")
@Produces("application/xml")
@Consumes("application/xml")
public abstract MyResponseType storeData(LargeJaxBClass xml);
}
public class LargeJaxBRequestEntity implements RequestEntity {
private final LargeJaxBClass large;
public LargeJaxBRequestEntity (LargeJaxBClass large)
{
this.large = large;
}
@Override
public boolean isRepeatable()
{
return true;
}
@Override
public void writeRequest(OutputStream outputstream) throws IOException {
try
{
Marshaller marshaller = localContext.createMarshaller();
marshaller.marshal(this.large, outputstream);
}
catch (Exception e) {
if (e instanceof IOException)
{
throw (IOException)e;
}
else
{
throw new IOException(e);
}
}
}
@Override
public long getContentLength()
{
return -1; //Length is not known
}
@Override
public String getContentType()
{
return "application/xml";
}
}