Hi, I'm
having trouble sending an image attachment from my client to the axis
webservice. The attachment seems to
go over fine but locks up my server and tries to write the binary data to the
console/screen (it also beeps like crazy, which makes me think it's a memory
problem). Any ideas as to what it is I'm doing wrong will be highly appreciated
(btw, I'm using tomcat 4.1.x, and message style webservices). ------------------------------------------------------------------------ ---- Here
is the code snippet on the client side: ------------------------------------------------------------------------ ---- Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress( "xxxx"); RemoteTaskRequest remoteTaskRequest =
new RemoteTaskRequest(); SOAPBodyElement[] soapRequest =new SOAPBodyElement[1];
String positionHTTPHeader="Ordinal";
String refs;
String setContentId="ScreenShot";
AttachmentPart ap= new AttachmentPart(new = DataHandler(new
FileDataSource("screenshot.jpg")));
ap.setContentId(setContentId);
refs = "cid:" + setContentId; //reference the attachment by
contentId.
ap.setMimeHeader(positionHTTPHeader, "" + 1 );
call.addAttachmentPart(ap);
String namespace="urn:foo";
StringBuffer msg = new StringBuffer("\n<attachments xmlns=\""
+namespace +"\">\n");
msg.append("
<attachment href="" + refs + = "\"/>\n");
msg.append(
"</attachments>");
call.setOperationStyle("document");
call.setOperationUse("literal");
soapRequest[0] = new SOAPBodyElement(new
ByteArrayInputStream(msg.toString().getBytes()));
call.invoke(soapRequest); ------------------------------------------------------------------------ ---- Here
is the code snippet on the server side: ------------------------------------------------------------------------ ----
AttachmentPart[] attachment getMessageAttachments();
private AttachmentPart[] getMessageAttachments() throws AxisFault
{
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg =
msgContext.getRequestMessage();
Attachments messageAttachments = reqMsg.getAttachmentsImpl();
if (null = messageAttachments) {
return new AttachmentPart[0];
}
int attachmentCount= messageAttachments.getAttachmentCount();
AttachmentPart attachments[] = new AttachmentPart[attachmentCount];
Iterator it = messageAttachments.getAttachments().iterator();
int count = 0;
while (it.hasNext()) {
AttachmentPart part = (AttachmentPart) it.next();
attachments[count++] = part;
}
return attachments;
} ------------------------------------------------------------------------ ---- Here
is my wsdl: ------------------------------------------------------------------------ ---- <?xml
version="1.0" encoding="UTF-8" ?> -
< http://xxxxxx > <wsdl:definitions
targetNamespace="http://xxxxxx" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://xxxxxx"
xmlns:intf="http://xxxxxx" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="http://xxxxxx"
= xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> -
< http://xxxxxx > <wsdl:types> -
< http://xxxxxx > <schema
targetNamespace="http://xxxxxx" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="setTaskResult"
type="xsd:anyType" /> </schema> -
< http://xxxxxx > <schema
targetNamespace="http://xxxxxx" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="setTaskResultReturn"
type="xsd:anyType" /> </schema> </wsdl:types> -
< http://xxxxxx > <wsdl:message
name="setTaskResultRequest"> <wsdl:part element="tns1:setTaskResult"
name="part" /> </wsdl:message> -
< http://xxxxxx > <wsdl:message
name="setTaskResultResponse"> <wsdl:part element="impl:setTaskResultReturn" name="setTaskResultReturn"
/> </wsdl:message> -
< http://xxxxxx > <wsdl:portType
name="RemoteTaskResultImpl"> -
< http://xxxxxx > <wsdl:operation
name="setTaskResult"> <wsdl:input message="impl:setTaskResultRequest" name="setTaskResultRequest"
/> <wsdl:output message="impl:setTaskResultResponse" name="setTaskResultResponse"
/> </wsdl:operation> </wsdl:portType> -
< http://xxxxxx > <wsdl:binding
name="remotetaskresultSoapBinding" type="impl:RemoteTaskResultImpl"> <wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" /> -
< http://xxxxxx> <wsdl:operation
name="setTaskResult"> <wsdlsoap:operation soapAction=""
/> -
< http://xxxxxx> <wsdl:input
name="setTaskResultRequest"> <wsdlsoap:body namespace="http://xxxxxx"
use="literal" /> </wsdl:input> -
< http://xxxxxx> <wsdl:output
name="setTaskResultResponse"> <wsdlsoap:body namespace="http://xxxxxx"
use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> -
< http://xxxxxx> <wsdl:service
name="RemoteTaskResultImplService"> -
< http://xxxxxx > <wsdl:port
binding="impl:remotetaskresultSoapBinding" name="remotetaskresult"> <wsdlsoap:address location="http://xxxxx"
/> </wsdl:port> </wsdl:service> </wsdl:definitions> ------------------------------------------------------------------------ ---- Thanx
in advance E. |