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 Koichi Kokura <ko...@cyp.co.jp> on 2004/09/14 05:51:57 UTC
DIME using gzip
Hi there,
I am tying to implement GZIP enabling Apache Axis. reffering follow URL.
http://www-106.ibm.com/developerworks/webservices/library/ws-sqzsoap.html
I have successed "version web service(Default Web Service)" using gzip,
But DIME Web service using gzip, AXIS can not handle it outputting follow
error.
Do anyone have a good idea to handle DIME using gzip?
Regards,
koki
Axis Error
----------------------------
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Content is not allowed in
prolog.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationCon
textImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at
com.test.recieveservice.client.webservices.DimeClientTest.run(DimeClientTest
.java:100)
at
com.test.recieveservice.client.webservices.DimeClientTest.main(DimeClientTes
t.java:48)
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:543)
at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
at org.apache.axis.client.Call.invokeEngine(Call.java:2583)
at org.apache.axis.client.Call.invoke(Call.java:2553)
at org.apache.axis.client.Call.invoke(Call.java:2248)
at org.apache.axis.client.Call.invoke(Call.java:2171)
at org.apache.axis.client.Call.invoke(Call.java:1691)
at
com.test.recieveservice.client.webservices.DimeClientTest.run(DimeClientTest
.java:100)
at
com.test.recieveservice.client.webservices.DimeClientTest.main(DimeClientTes
t.java:48)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
at
org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationCon
textImpl.java:242)
at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
... 8 more
------------------------
TCPMonitor HTTPHeader
------------------------
<Request>
POST /axis/services/recieveservice?wsdl HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.1
Host: 127.0.0.1
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 450
Accept-Encoding: gzip
・
・
・
------------------------
<Response>
HTTP/1.1 200 OK
Content-Encoding: gzip
Date: Tue, 14 Sep 2004 02:15:34 GMT
Server: Apache-Coyote/1.1
Connection: close
・
・
・
------------------------
Client Source
------------------------
package com.test.recieveservice.client.webservices;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.axis.attachments.AttachmentPart;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.message.SOAPEnvelope;
import javax.xml.rpc.ParameterMode;
import javax.xml.soap.SOAPBody;
import javax.xml.namespace.QName;
import java.net.URL;
import java.util.Iterator;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import
localhost.jp_ikepon_app_gzipaxisservletsample.services.Version.Version;
import
localhost.jp_ikepon_app_gzipaxisservletsample.services.Version.VersionServic
e;
import
localhost.jp_ikepon_app_gzipaxisservletsample.services.Version.VersionServic
eLocator;
public class DimeClientTest {
String filePass = "C:\\RespocseFiles\\";
public static void main(String[] args)
{
DimeClientTest obj = new DimeClientTest();
obj.run(args);
}
public void run(String[] args)
{
Service service = null;
Call call = null;
File dirsin = new File(filePass);
dirsin.mkdirs();
String fileName = args[0];
try
{
service = new Service();
call = (Call)service.createCall();
call.setTargetEndpointAddress(new
URL("http://localhost:8090/axis/services/recieveservice?wsdl"));
call.setOperationName(new QName("recieveservice", "hello"));
Object ret = call.invoke(new Object[]{fileName});
Iterator iterator = call.getResponseMessage().getAttachments();
AttachmentPart part = (AttachmentPart) iterator.next();
fileName = fileName.substring(fileName.lastIndexOf("\\") + 1);
FileOutputStream fs = null;
try
{
fs = new FileOutputStream(filePass + fileName);
part.getDataHandler().writeTo(fs);
fs.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
------------------------
Server Source
------------------------
package com.test.recieveservice.server;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.transform.dom.DOMSource;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.attachments.AttachmentPart;
import org.w3c.dom.Document;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
public class DimeService {
String folder = "D:/javasrc/dynaplant/classes/";
public boolean hello(String filename)
{
try
{
MessageContext ctx = MessageContext.getCurrentContext();
org.apache.axis.Message rspMsg= ctx.getResponseMessage();
rspMsg.getAttachmentsImpl().setSendType(org.apache.axis.attachments.Attachme
nts.SEND_TYPE_DIME);
AttachmentPart ap = new AttachmentPart(new DataHandler(new
FileDataSource(folder+filename)));
ap.setContentType("image");
rspMsg.addAttachmentPart(ap);
return true;
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
}
------------------------
WSDD
------------------------
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions
targetNamespace="http://test.com/recieveservice/client/webservices"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://test.com/recieveservice/client/webservices"
xmlns:intf="http://test.com/recieveservice/client/webservices"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:message name="helloResponse">
<wsdl:part name="helloReturn" type="xsd:boolean" />
</wsdl:message>
- <wsdl:message name="helloRequest">
<wsdl:part name="filename" type="xsd:string" />
</wsdl:message>
- <wsdl:portType name="DimeService">
- <wsdl:operation name="hello" parameterOrder="filename">
<wsdl:input message="impl:helloRequest" name="helloRequest" />
<wsdl:output message="impl:helloResponse" name="helloResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="recieveserviceSoapBinding" type="impl:DimeService">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="hello">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="helloRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://test.com/recieveservice/client/webservices" use="encoded"
/>
</wsdl:input>
- <wsdl:output name="helloResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://test.com/recieveservice/client/webservices" use="encoded"
/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="DimeServiceService">
- <wsdl:port binding="impl:recieveserviceSoapBinding" name="recieveservice">
<wsdlsoap:address location="http://localhost/axis/services/recieveservice"
/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
------------------------