You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Frank Starsinic <fs...@apengines.com> on 2001/01/04 20:16:44 UTC
RE: vs. SUCCESS (and a follow up question)
OK i got it to work.
i needed to use this encoding style.
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
thanks simon!
i have one more question for someone. then i'll be an expert. :)
(i've included the xml file, the resulant soap packet and the java snippet
i tried to get it to work.)
how do i create the soap packet (below) using the apache SOAP API given
that the only information i know is the following xml file
######################################### xml file
#########################################
<Serviceability>
<EXTERN_SYS_XREF>255</EXTERN_SYS_XREF>
<WFE_TRAN_TYPE>SERVICEABILITY</WFE_TRAN_TYPE>
<ADDRESS1>4308 ALLEN DR</ADDRESS1>
<ADDRESS2></ADDRESS2>
<CITY>COLUMBUS</CITY>
<STATE>OH</STATE>
<ZIP>43213</ZIP>
<ZIP4></ZIP4>
<HOME_PHONE>6143956456</HOME_PHONE>
<ACCOUNT_NO></ACCOUNT_NO>
<HOUSE_KEY></HOUSE_KEY>
<STATUS_CODE>0</STATUS_CODE>
<ERROR_CODE>0</ERROR_CODE>
<DESCR></DESCR>
<FRANK>test</FRANK>
</Serviceability>
i don't have a problem generating the http header, just the xml
part.
here is the soap packet that works that i need to generate using the apache
soap api.
######################################### soap packet
#########################################
POST /Mentis/Mentis.asp HTTP/1.0
Host: localhost:8080
Content-Type: text/xml
Content-Length: 1081
SOAPAction: http://twc/Mentis/Mentis.asp#Serviceability
<?xml version="1.0"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<Serviceability>
<EXTERN_SYS_XREF>255</EXTERN_SYS_XREF>
<WFE_TRAN_TYPE>SERVICEABILITY</WFE_TRAN_TYPE>
<ADDRESS1>4308 ALLEN DR</ADDRESS1>
<ADDRESS2></ADDRESS2>
<CITY>COLUMBUS</CITY>
<STATE>OH</STATE>
<ZIP>43213</ZIP>
<ZIP4></ZIP4>
<HOME_PHONE>6143956456</HOME_PHONE>
<ACCOUNT_NO></ACCOUNT_NO>
<HOUSE_KEY></HOUSE_KEY>
<STATUS_CODE>0</STATUS_CODE>
<ERROR_CODE>0</ERROR_CODE>
<DESCR></DESCR>
<FRANK>test</FRANK>
</Serviceability>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
it should be something like this but i can't quite get it.....
######################################### java snippet
#########################################
import org.w3c.dom.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.*;
import org.apache.soap.encoding.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class Test
{
public static void main (String args[])throws
java.net.MalformedURLException,
java.io.FileNotFoundException,
java.io.IOException,
java.lang.NullPointerException
{
URL url = new URL("http://" + args[1] + "/Mentis/Mentis.asp");
Reader UserFile = new FileReader(xml_location);
XMLParserLiaison xpl = new XercesParserLiaison();
Document doc = xpl.read("- User File -", UserFile);
Element root = doc.getDocumentElement();
// Build the call.
Call call = new Call();
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
//################ the problem is down here somewhere. i don't know
what the @#$%^ i'm doing #######
params.addElement(new Parameter("Serviceability",
Element.class,root, Constants.NS_URI_LITERAL_XML));
call.setParams(params);
// Invoke the call.
Response resp;
try
{
resp = call.invoke(url, "");//Invoke this call at the specified
URL.
} catch (SOAPException e)
{
System.out.println("Caught SOAPException (" + e.getFaultCode() +
"): " + e.getMessage());
return;
}
System.out.println("generatedFault()?"+resp.generatedFault());
// resp.getFault().setFaultString("sds");
if (!resp.generatedFault())
{
System.out.println("1");
Parameter ret = resp.getReturnValue();
System.out.println("EncodingStyleURI"+ret.getEncodingStyleURI());
Element rspE1 = (Element)ret.getValue();
System.out.println("2");
Element e = (Element)ret.getValue();
System.out.println("3");
strResponse = DOM2Writer.nodeToString(rspE1);
System.out.println(strResponse);
System.out.println("4");
byte b[] = new byte[strResponse.length()];
System.out.println("5");
b = strResponse.getBytes();
FileOutputStream fo = new
FileOutputStream("QuerySubscriber_Response.xml");
fo.write(b);
fo.close();
System.out.println("6");
} else
{
Fault fault = resp.getFault();
System.out.println("Generated fault: ");
System.out.println (" Fault Code = " + fault.getFaultCode());
System.out.println (" Fault String = " +
fault.getFaultString());
System.out.println ("bjbvckdbvksvpvkp"+
fault.getDetailEntries().toString());
}
}
}
thanks a million,
frank