[hopeully this will come out a bit better] As a relative beginner to SOAP. I've got a few questions about it in general and how I can use AXIS to answer them.
First off, I currently exchange XML over other protocols like HTTP, FTP, etc. So I generate this XML as a completely separate process. One of our new business partners can either receive our XML via SOAP or an HTTP post. The SOAP message is expected to look like this: <customSOAPPrefix:Envelope xmlns:customSOAPPrefix="http://schemas.xmlsoap.org/soap/envelope/"> <customSOAPPrefix:Body> <customMsgPrefix:Request xmlns:customMsgPrefix="http://www.xyz.com/request/"> <paramXML> [my XML message goes here] </paramXML> </customMsgPrefix:Request> </customSOAPPrefix:Body> </customSOAPPrefix:Envelope> I have a few questions about this: -I know the prefix's should not matter but in this case they do. In the java constants class these soap prefixes are final, so I cannot modify them. I also can't seem to get access to the serializer used, so I can't add a prefix/namespace mapping. Yes, its been asked here many times before, but searching the archives I can't find an answer. -Is there anyway to change the prefixes used? -I've tried the following operation/encoding/type scenarios with varying success. Note: -I'm setting the custom AXIS parameter SEND_TYPE_ATTR to false since I do not want this. -- Important for possible bugs outlined below. -I'm specifying my operation using the namespace uri above. -- Important for possible bugs outlined below. -My partner is validating against a schema so any extra attibutes are failures. -- Is there any way to avoid the encodingStyle attribute from being sent with soap1.1 encoding? -Even though I set SOAPACTION_USE_PROPERTY to false, it still gets passed as "" -- bug? -Many of these possible bugs are my ignorance to the specs. Please just point me in the right direction if this is the case. Operation Encoding Parameter Type Result rpc soap1.1 string xml param encoded (< goes to <) extra attributes for encoding and type passed -- bug? rpc literal string xml param encoded -- bug? extra attribute type passed on param-- bug? operation has no prefix for namespace -- bug? bogus empty namespace ("") put on param -- bug? rpc soap1.1 element xml param not encoded -- cool extra attribute type passed on param-- bug? rpc literal element xml param not encoded -- cool attribute "type" passed on param -- bug? namespace on operation now ignored -- bug? document * * operation not sent as element for any combinations -- bug? wrapped soap1.1 string xml param not encoded -- bug? attribute "type" passed on param -- bug? wrapped literal string xml param not encoded -- cool operation has no prefix for namespace -- bug? attribute "type" passed on param -- bug? bogus empty namespace ("") put on param -- bug? wrapped soap1.1 element xml param not encoded -- not sure on this? extra attribute type passed on param-- bug? rpc literal element xml param not encoded -- cool attribute "type" passed on param -- bug? namespace on operation now ignored -- bug? Here is my sample code for the previous tests: import javax.xml.rpc.ParameterMode; import javax.xml.rpc.Call; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; import javax.xml.rpc.encoding.XMLType; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; import java.io.*; public class MyTest { public static void main(String [] args) { //SerilizationContext.getPrefixForURI( String uri ); try { String endpoint = "http://localhost:32124/test"; QName serviceName = new QName("MyTest"); QName opName = new QName("http://www.xyz.com/request/", "Request"); QName portName = new QName( "http://localhost:32124/test" ); ServiceFactory sf = ServiceFactory.newInstance(); Service service = sf.createService( serviceName ); Call call = service.createCall(); call.setProperty( Call.SOAPACTION_USE_PROPERTY, Boolean.FALSE ); //call.setProperty( Call.OPERATION_STYLE_PROPERTY, "rpc" ); call.setProperty( Call.OPERATION_STYLE_PROPERTY, "wrapped" ); // "" means literal encoding //call.setProperty( Call.ENCODINGSTYLE_URI_PROPERTY , "http://schemas.xmlsoap.org/soap/encoding/" ); call.setProperty( Call.ENCODINGSTYLE_URI_PROPERTY , "" ); call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE); call.setTargetEndpointAddress( endpoint ); call.setOperationName( opName ); //QName type = org.apache.axis.Constants.SOAP_STRING; QName type = org.apache.axis.Constants.SOAP_ELEMENT; call.addParameter( "strXML", type, ParameterMode.IN ); // This doesn't help my empty namespace problem... :( //((org.apache.axis.client.Call)call).addParameter( new QName( null, "strXML"), type, ParameterMode.IN ); call.setReturnType( type ); // build the document String xml = "<TRANSACTION><HEADER>yadda yadda1234</HEADER></TRANSACTION>"; ByteArrayInputStream input = new ByteArrayInputStream( xml.getBytes() ); DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = builder.parse( input ); Element frag = doc.getDocumentElement(); Object o = call.invoke( new Object[] { frag } ); } catch (Exception e) { e.printStackTrace(); } } }
