Hi Andrew,
After Lunch I wrote the client this way now:
---------------
public class WebserviceClient extends DefaultHandler
{
EmailLog _elog;
String _actualValue = "";
File xmlFile = new String("d:\\java\\ws\\testfile.xml");
public static void main(String argv[]) {
/*Parse the source XML File */
/**********************************************************/
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document parsedDoc = db.parse (xmlFile);
Service service = new Service();
Call call = (Call)service.createCall();
opts.setDefaultURL(
"http://localhost:8080/axis/servlet/AxisServlet" );
/* Set all of the stuff that would normally come from WSDL */
/***********************************************************/
call.setTargetEndpointAddress( new URL(opts.getURL()) );
call.setUseSOAPAction( true );
call.setSOAPActionURI( "doWrite" );
call.setEncodingStyle( "http://schemas.xmlsoap.org/soap/encoding/" );
call.setOperationName( new QName("urn:webservice", "doWrite") );
call.addParameter( "xmlDataBody", XMLType.XSD_STRING,
ParameterMode.IN );
call.setReturnType( XMLType.XSD_BOOLEAN );
/* Define some service specific properties */
/*******************************************/
call.setUsername( opts.getUser() );
call.setPassword( opts.getPassword() );
/* Invoke the service */
/*************************************/
SOAPBodyElement[] input = new SOAPBodyElement[1];
Element bodyElement = parsedDoc.getDocumentElement();
SOAPBodyElement sbe = new SOAPBodyElement(bodyElement);
sbe.setNamespaceURI("");
input[0] = sbe;
boolean written = call.invoke( input );
System.exit(0);
}
}
If I extract the Document in my web service like
SOAPBodyElement sbe = input[0];
Element elem = sbe;
NodeList list = elem.getElementsByTagName ("field");
...
it should work, right?
By the way, I am an german intern and in the US since march this year.
Thanks for your support!
Mark.
>Mark,
>
>I suggest you do the following:
>
>parse the XML document. Use the DOM Document.getDocumentElement() method
>to get the document element of the document. Create a SOAPBodyElement from
>this DOM Element. Invoke the service with an array containing only this
>SOAPBodyElement. On the wire, you can look at this SOAP Envelope and see
>that your entire XML document, minus the xml declaration and any comments,
>etc. you had outside the document's root element. Assuming you can afford
>to lose these things, it's easy to write a service that extracts the whole
>DOM on the other end (again, see the axis message example). Here is some
>client code that I'm using to do the same thing:
>
> // parse document into Document object parsedDoc
>
> SOAPBodyElement[] input = new SOAPBodyElement[1];
>
> Element bodyElement = parsedDoc.getDocumentElement();
> SOAPBodyElement sbe = new SOAPBodyElement(bodyElement);
> sbe.setNamespaceURI("");
> input[0] = sbe;
>
> Vector elems = (Vector) call.invoke( input );
>
>
>Andrew