SOAPException for MimeTest on WebLogic 8.1

L

Leslie

Hi,

I'm trying on the MimeTest sample that comes with apache soap. I have
deployed the service on WebLogic Server 8.1 using JBuilderX. I modfied
the MimeTestClient to run only the sendFile service. But I got the
SOAPException below. Attached is also the code for MimeTestClient.java.
I found a post on the Net with similar problem but there was no reply.
How do I resolve the problem? Thanks in advance.

--------------------------------------------------------------
Response:

Caught SOAPException (SOAP-ENV:protocol): Unsupported response content
type "text/html", must be: "text/xml". Response was:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">
<HTML>
<HEAD>
<TITLE>Error 403--Forbidden</TITLE>
<META NAME="GENERATOR" CONTENT="WebLogic Server">
</HEAD>
<BODY bgcolor="white">
<FONT FACE=Helvetica><BR CLEAR=all>
<TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all>
<FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error
403--Forbidden</H2>
</FONT></TD></TR>
</TABLE>
<TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100%
BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica"
SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol --
HTTP/1.1</i>:</H3>
</FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.4 403 Forbidden</H4>
</FONT><P><FONT FACE="Courier New">The server understood the request,
but is refusing to fulfill it. Authorization will not help and the
request SHOULD NOT be repeated. If the request method was not HEAD and
the server wishes to make public why the request has not been
fulfilled, it SHOULD describe the reason for the refusal in the entity.
This status code is commonly used when the server does not wish to
reveal exactly why the request has been refused, or when no other
response is applicable.</FONT></P>
</FONT></TD></TR>
</TABLE>
</BODY>
</HTML>
[SOAPException: faultCode=SOAP-ENV:protocol; msg=Unsupported response
content type "text/html", must be: "text/xml". Response was:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Draft//EN">
<HTML>
<HEAD>
<TITLE>Error 403--Forbidden</TITLE>
<META NAME="GENERATOR" CONTENT="WebLogic Server">
</HEAD>
<BODY bgcolor="white">
<FONT FACE=Helvetica><BR CLEAR=all>
<TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all>
<FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error
403--Forbidden</H2>
</FONT></TD></TR>
</TABLE>
<TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100%
BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica"
SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol --
HTTP/1.1</i>:</H3>
</FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.4 403 Forbidden</H4>
</FONT><P><FONT FACE="Courier New">The server understood the request,
but is refusing to fulfill it. Authorization will not help and the
request SHOULD NOT be repeated. If the request method was not HEAD and
the server wishes to make public why the request has not been
fulfilled, it SHOULD describe the reason for the refusal in the entity.
This status code is commonly used when the server does not wish to
reveal exactly why the request has been refused, or when no other
response is applicable.</FONT></P>
</FONT></TD></TR>
</TABLE>
</BODY>
</HTML>

------------------------------------------------------------
MimeTestClient.java:

public class MimeTestClient {
public static void main(String[] args) throws Exception {
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
URL url = new URL("http://localhost:7001/Mime-web-services/");
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();

try {
// Build the call.
Call call = new Call();

call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("urn:mimetest");
call.setMethodName("sendFile");
call.setEncodingStyleURI(encodingStyleURI);

Vector params = new Vector();

for (int i = 0; i < args.length; i++) {
DataSource ds = new ByteArrayDataSource(new
File("C:\\changes.jpg\\"),
null);
DataHandler dh = new DataHandler(ds);
params.addElement(new Parameter("addedfile",

javax.activation.DataHandler.class,
dh, null));
}
call.setParams(params);
Response resp;

try {
resp = call.invoke(url, "");
} catch (SOAPException e) {
System.err.println("Caught SOAPException (" +
e.getFaultCode() + "): " +
e.getMessage());
e.printStackTrace();
return;
}

// Check the response.
if (!resp.generatedFault()) {
Parameter ret = resp.getReturnValue();
if(ret == null)
System.out.println("No response.");
else {
// System.out.println("Response: " + resp);

printObject(ret.getValue());
}
} else {
Fault fault = resp.getFault();

System.err.println("Generated fault: " + fault);
}
} catch(Exception e) {
e.printStackTrace();
}

public static void printObject(Object obj) {
if (obj instanceof DataHandler) {
DataHandler dh = (DataHandler)obj;
Object o;
try {
o = dh.getContent();
} catch(IOException ioe) {
o = ioe;
}
System.out.println("DataHandler, name=" + dh.getName()
+ ", type=" + dh.getContentType()
+ ", content: (" + o.getClass().getName()
+ ")\n" + o);
DataSource ds = dh.getDataSource();
String fname = "" + System.currentTimeMillis() + ".out";
System.out.println(" Writing attachment to file: " + fname);
try {
ByteArrayDataSource bds = new ByteArrayDataSource(
ds.getInputStream(), dh.getContentType());
bds.writeTo(new FileOutputStream(fname));
} catch(IOException ioe) {
System.out.println(ioe);
ioe.printStackTrace(System.err);
}
} else if (obj instanceof Vector) {
for(Enumeration enum = ((Vector)obj).elements();
enum.hasMoreElements(); )
printObject(enum.nextElement());
} else if (obj instanceof Object[]) {
Object[] s = (Object[])obj;
for (int i = 0; i < s.length; i++)
printObject(s);
} else
System.out.println(obj);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top