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 john smith <gr...@yahoo.com> on 2004/11/30 08:30:51 UTC
returning multiple parameters - including datahandler
Hi All,
I am new to Axis. I have a simple SOAP service which returns a datahandler.
I also want to return another paramater such as filesize or filename in my message body. What is a good way to do this? Does anyone have any code examples? I am using Axis 1.1.
Basically I want the body to contain
<myparameter> myvalue <myparameter>
Below is my client and service.
Client:
call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
call.setOperationName( new QName("urn:dhService", "myMethod") );
call.addParameter( "arg1", XMLType.XSD_STRING, ParameterMode.IN);
QName qnameAttachment = new QName("urn:dhService", "DataHandler");
call.registerTypeMapping(javax.activation.DataHandler.class,
qnameAttachment,
JAFDataHandlerSerializerFactory.class,
JAFDataHandlerDeserializerFactory.class);
call.setReturnType(qnameAttachment);
DataHandler ret = (DataHandler) call.invoke( new Object [] { textToSend } );
Service:
public DataHandler myMethod(String arg)
{
try {
URL url = new URL("file:///myfile.txt");
DataHandler dh = new DataHandler(url);
return dh;
...
This produces the following XML response:
HTTP/1.1 200 OK
Content-Type: multipart/related; type="text/xml"; start="<8740D307B85F91BD06BF53BA1D26550C>"; boundary="----=_Part_2_15198443.1101775257325"
Date: Tue, 30 Nov 2004 00:40:57 GMT
Server: Apache-Coyote/1.1
Connection: close
------=_Part_2_15198443.1101775257325
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: binary
Content-Id: <8740D307B85F91BD06BF53BA1D26550C>
<?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>
<ns1:myMethodResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:dhService">
<ns1:myMethodReturn href="cid:3B3512781AF5D97113F0079CBF087495" xmlns:ns2="http://xml.apache.org/xml-soap"/>
</ns1:myMethodResponse>
</soapenv:Body>
</soapenv:Envelope>
------=_Part_2_15198443.1101775257325
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-Id: <3B3512781AF5D97113F0079CBF087495>
...blah...
------=_Part_2_15198443.1101775257325--
Thanks for your help in advance.
---------------------------------
Do you Yahoo!?
The all-new My Yahoo! � Get yours free!
Re: returning multiple parameters - including datahandler
Posted by V D <st...@drexel.edu>.
I wonder if this has something to some buffered flag. Did you try to
send some small text file attachment? If it works, then it could be the
size of the file you send (Tomcat could limit the size that you can post
to it, I think you can change this limit somewhere in the
configuration). Don't jump into conclusion yet. Use TcpMon, and send a
small text attachment, and see what's going through the wire. I am not
sure if this has anything to do with it or not, but try change the URL
parameter into a FileDataSource and pass that into the DataHandler instead.
Re: returning multiple parameters - including datahandler
Posted by john smith <gr...@yahoo.com>.
Thanks Vy,
I tried this and it worked on my win enviroment. Delpoying on linux I get the following error.
$ java batchEx.ClientWSDD3 -lhttp://localhost:8082/axis/services/BatchService test
Calling Service
- Exception:
java.lang.RuntimeException: javax.mail.MessagingException: Error in input stream;
nested exception is:
java.io.IOException: End of stream encountered before final boundary marker.AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: javax.mail.MessagingException: Error in input stream;
nested exception is:
java.io.IOException: End of stream encountered before final boundary marker.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: javax.mail.MessagingException: Error in input stream;
nested exception is:
java.io.IOException: End of stream encountered before final boundary marker.
at javax.mail.internet.InternetHeaders.load(InternetHeaders.java:143)
at javax.mail.internet.InternetHeaders.<init>(InternetHeaders.java:93)
at org.apache.axis.attachments.MultiPartRelatedInputStream.readTillFound(MultiPartRelatedInputStream.java:545)
at org.apache.axis.attachments.MultiPartRelatedInputStream.readAll(MultiPartRelatedInputStream.java:472)
at org.apache.axis.attachments.MultiPartRelatedInputStream.getAttachments(MultiPartRelatedInputStream.java:485)
at org.apache.axis.attachments.AttachmentsImpl.mergeinAttachments(AttachmentsImpl.java:190)
at org.apache.axis.attachments.AttachmentsImpl.getAttachmentByReference(AttachmentsImpl.java:349)
at org.apache.axis.encoding.DeserializationContextImpl.getObjectByRef(DeserializationContextImpl.java:555)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:386)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:976)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:404)
at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:165)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:976)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
at org.apache.axis.client.Call.invoke(Call.java:2272)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at batchEx.ClientWSDD3.main(ClientWSDD3.java:111)
javax.mail.MessagingException: Error in input stream;
nested exception is:
java.io.IOException: End of stream encountered before final boundary marker.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.attachments.MultiPartRelatedInputStream.readTillFound(MultiPartRelatedInputStream.java:655)
at org.apache.axis.attachments.MultiPartRelatedInputStream.readAll(MultiPartRelatedInputStream.java:472)
at org.apache.axis.attachments.MultiPartRelatedInputStream.getAttachments(MultiPartRelatedInputStream.java:485)
at org.apache.axis.attachments.AttachmentsImpl.mergeinAttachments(AttachmentsImpl.java:190)
at org.apache.axis.attachments.AttachmentsImpl.getAttachmentByReference(AttachmentsImpl.java:349)
at org.apache.axis.encoding.DeserializationContextImpl.getObjectByRef(DeserializationContextImpl.java:555)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:386)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:976)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
at org.apache.axis.encoding.DeserializerImpl.startElement(DeserializerImpl.java:404)
at org.apache.axis.encoding.ser.BeanDeserializer.startElement(BeanDeserializer.java:165)
at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:976)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
at org.apache.axis.client.Call.invoke(Call.java:2272)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at batchEx.ClientWSDD3.main(ClientWSDD3.java:111)
Caused by: javax.mail.MessagingException: Error in input stream;
nested exception is:
java.io.IOException: End of stream encountered before final boundary marker.
at javax.mail.internet.InternetHeaders.load(InternetHeaders.java:143)
at javax.mail.internet.InternetHeaders.<init>(InternetHeaders.java:93)
at org.apache.axis.attachments.MultiPartRelatedInputStream.readTillFound(MultiPartRelatedInputStream.java:545)
... 20 more
My service looks like:
public String serviceMethod(String arg)
public DataHandler batchMethod(String arg)
URL url = new URL("file:///file.txt");
System.out.println("setting dh");
DataHandler dh = new DataHandler(url);
return dh;
public MyReturnedStuffs obMethod(String arg)
MyReturnedStuffs mrs = new MyReturnedStuffs();
mrs.setFilename("file.txt");
URL url = new URL("file:///file.txt");
System.out.println("setting file");
mrs.setFile(new DataHandler(url));
System.out.println("returning mrs");
return mrs;
When I call obMethod or batchMethod I get the error. ServiceMethod works.
Client for obMethod
QName qnameAttachment = new QName("urn:BatchService", "MyReturnedStuffs");
call.registerTypeMapping(MyReturnedStuffs.class,
qnameAttachment,
new BeanSerializerFactory(MyReturnedStuffs.class, qnameAttachment),
new BeanDeserializerFactory(MyReturnedStuffs.class, qnameAttachment));
call.setReturnType(qnameAttachment);
try {
MyReturnedStuffs ret = (MyReturnedStuffs) call.invoke( new Object [] { textToSend } );
I have the
same Mail.jar and Acrivation.jar ,
Axis 1.1,
Tomcat ( 4 on linux 5 on win)
Is this due to some classpath/env error or is it something else that anyone can identify?
Any help would be appreciated. Thanks in Advance.
Vy Ho <st...@drexel.edu> wrote:
Can you wrap all things that you want to return in a class, then call
that instead:
class MyReturnedStuffs{
int status;
String whatever;
DataHandler data;
}
public MyReturnedStuffs doit(...){
}
---------------------------------
Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more.
Re: returning multiple parameters - including datahandler
Posted by Vy Ho <st...@drexel.edu>.
Can you wrap all things that you want to return in a class, then call
that instead:
class MyReturnedStuffs{
int status;
String whatever;
DataHandler data;
}
public MyReturnedStuffs doit(...){
}