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 Ying Foong <yi...@dsssasia.com> on 2004/01/19 07:19:11 UTC
Internal Server Error - help
Hello,
i'm using Axis 1.2alpha and it was working fine with the codes below. But
recently it returns me an "Internal Server Error" 500, I did not change
anything on the code but it suddenly down.
can somebody help me in this issue? it will be greatly appreciated.
i sent the soap document below:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<test:echoOk env:mustUnderstand="1"
xmlns:test="http://example.org/ts-tests">foo</test:echoOk>
</env:Header>
<env:Body>
<test:echoOk xmlns:test="http://example.org/ts-tests">foo</test:echoOk>
</env:Body>
</env:Envelope>
server-side code
import org.w3c.dom.*;
import org.apache.axis.message.*;
import org.apache.axis.*;
//import javax.xml.soap.SOAPBody;
//import javax.xml.soap.SOAPHeader;
import javax.xml.soap.Name;
import java.util.Iterator;
public class MessageService {
private String prefix = "test";
private String body = "Body";
private String header = "Header";
private String role = "role";
private String mustUnderstand = "mustUnderstand";
private Node rootNode;
private Element rootElement;
//private String content = "";
private String nodeAURI = "http://example.org/ts-tests/A";
private String nodeBURI = "http://example.org/ts-tests/B";
private String nodeCURI = "http://example.org/ts-tests/C";
private String defaultNodeURI = "http://example.org/ts-tests";
private String xsdURI = "http://example.org/ts-tests/xsd";
private String ultimateReceiverURI =
"http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver";
private String nextRoleURI =
"http://www.w3.org/2003/05/soap-envelope/role/next";
private String noneRoleURI =
"http://www.w3.org/2003/05/soap-envelope/role/none";
private String encodingStyle = "encodingStyle";
private static final String XMLNS = "xmlns";
private String enc = "enc";
private String xsd = "xsd";
private String xsi = "xsi";
private static final String interopURI = "http://soapinterop.org/";
private static final String xsdinteropURI = "http://soapinterop.org/xsd";
private static final String NS_ENVOLD =
"http://schemas.xmlsoap.org/soap/envelope/";
private static final String NS_ENCOLD =
"http://schemas.xmlsoap.org/soap/encoding/";
private static final String NS_ENV =
"http://www.w3.org/2003/05/soap-envelope";
private static final String NS_ENC =
"http://www.w3.org/2003/05/soap-encoding";
private static final String NS_XSD = "http://www.w3.org/2001/XMLSchema";
private static final String NS_XSI =
"http://www.w3.org/2001/XMLSchema-instance";
private String[] headerBlocks = {"echoOk", "responseOk",
"Ignore","requiredHeader", "DataHolder",
"concatAndForwardEchoOk","concatAndForwardEchoOkArg1",
"concatAndForwardEchoOkArg2","validateCountryCode",
"validateCountryCodeFault","echoResolvedRef", "responseResolvedRef"};
private String[] bodyBlocks = {"echoOk", "responseOk", "echoHeader",
"echoHeaderResponse"};
private String[] RPCMethods = {"returnVoid", "echoStruct",
"echoStructArray", "echoStructAsSimpleTypes",
"echoSimpleTypesAsStruct", "echoNestedArray", "echoFloatArray",
"echoStringArray", "echoIntegerArray", "echoBase64",
"echoBoolean",
"echoDate", "echoDecimal", "echoFloat", "echoString",
"countItems",
"isNil"};
public void Envelope(SOAPEnvelope reqenv, SOAPEnvelope resenv){
try{
this.rootElement = reqenv.getAsDOM();
this.rootNode = rootElement;
Node envNode = rootNode.getParentNode();
String envPrefix = envNode.getFirstChild().getPrefix();
String env = envNode.getFirstChild().getLocalName();
Name headerName = resenv.createName("responseOk", "test",
"http://example.org/ts-tests");
SOAPHeaderElement headerElement = new SOAPHeaderElement(headerName);
resenv.addHeader(headerElement);
headerElement.addTextNode(getTextValue(rootElement, envPrefix, "Header",
"test", "echoOk"));
}
SOAPBodyElement reqBodyElement = reqenv.getFirstBody();
Name reqBodyName = reqBodyElement.getElementName();
Name resBodyName = resenv.createName("responseOk", "test",
"http://example.org/ts-tests");
SOAPBodyElement resBodyElement = new SOAPBodyElement(resBodyName);
resenv.addBodyElement(resBodyElement);
resBodyElement.addTextNode(getTextValue(rootElement, envPrefix,
"Body","test", "echoOk"));
}catch (Exception e){
e.printStackTrace();
}
}
private String getTextValue(String SOAPPrefix, String SOAPLocalName, String
prefix, String localName){
String content = "";
NodeList headerList = rootElement.getElementsByTagName(SOAPPrefix + ":" +
SOAPLocalName);
NodeList childList = headerList.item(0).getChildNodes();
for (int k = 0; k < childList.getLength(); k++){
Node childNode = childList.item(k); // to shorten the object name
if (childNode.getNodeType() == childNode.ELEMENT_NODE &&
childNode.getPrefix().compareTo(prefix) == 0 &&
childNode.getLocalName().compareTo(localName)== 0){
if (childNode.getFirstChild().getNodeType() == childNode.TEXT_NODE){
content += childList.item(k).getNodeName() + k;
}
}
}
return content;
}
}
Phoon Ying Foong
Software Engineer
Data Security Systems Solutions Pte Ltd.
phone(office):(+65)62959102
phone(mobile):(+65)94854045
Email: yingfoong@dsssasia.com