Hi all; first of all i want to thank Anne Thomas Manes for her tips.
I want to ask a thing i have a web service built in java; it is a java class 
that has several methods.
Now in my axis.wsdd i have added a service like this one:
    <service name="Interaction" type="" regenerateElement="false"
        provider="java:MSG" style="message" use="literal" validate="false">
        <parameter name="scope" value="Request" regenerateElement="false"/>
        <parameter name="className"
            value="it.eng.napsi.websrv.javabean.Interaction" 
regenerateElement="false"/>
        <parameter name="allowedMethods" value="*" regenerateElement="false"/>
        <namespace>http://javabean.websrv.napsi.eng.it</namespace>
        <operation name="byFiscalCode"
            returnQName="ns1:byFiscalCodeReturn"
            returnType="xsd:anyType" qname="ns1:byFiscalCode"
            regenerateElement="false" 
xmlns:ns1="http://javabean.websrv.napsi.eng.it"/>
    </service>

Now i have this simple client:
package it.eng.test.client.util;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPBody;
import org.apache.axis.utils.XMLUtils;
import javax.xml.rpc.ServiceException;

import java.util.Vector;
import org.w3c.dom.Document;
import javax.xml.namespace.QName;

import org.apache.log4j.Logger;
import java.net.URL;
import java.net.MalformedURLException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.util.*;

import it.eng.napsi.input.individuo.IndividualMarshaller;


public class SimpleAxisClient {
    public SimpleAxisClient() {
    }

    private static final Logger LOG = Logger.getLogger(SimpleAxisClient.class.
            getName());


    private Call getCall(String endpoint, String operation) throws
            ServiceException {

        if (LOG.isDebugEnabled()) {

            LOG.debug("Creating call.....");
        }
        Call result = (Call) (new Service()).createCall();
        try {
            result.setTargetEndpointAddress(new URL(endpoint));

        } catch (MalformedURLException ex) {

            LOG.error(ex);
        }

        result.setOperation(new QName(endpoint, operation), operation);
        if (LOG.isDebugEnabled()) {

            LOG.debug("Done!!");
        }
        return result;
    }

    public Document getDocument(Document doc, String endpoint,
                                String operation) throws Exception {
        Call call = getCall(endpoint, operation);
        Vector result = (Vector) call.invoke(new Object[] {doc});
        //Vector result = (Vector) call.invoke(new SOAPBodyElement[] { new 
SOAPBodyElement( doc.getDocumentElement() )});
        SOAPBodyElement sbe = (SOAPBodyElement) result.get(0);

        if (LOG.isDebugEnabled()) {

            LOG.debug("Body ricevuto: " +
                      XMLUtils.DocumentToString(sbe.getAsDocument()));
        }
        return sbe.getAsDocument();
    }

    public static void main(String args[]) throws Exception {

        IndividualMarshaller ind = new IndividualMarshaller();
        Map envi = new Hashtable();
        envi.put( "codFisc","MMDNGL74C22H703K" );
        //String xmlString = ind.toStringDocument( envi );
        /*
        String xmlString = "<impl:doc 
xmlns:impl='http://javabean.websrv.napsi.eng.it'>"+
                           
"<ricercaIndividuo><codiceFiscale>XXXXXXXXXXXXX</codiceFiscale>"+
                           "</ricercaIndividuo></impl:doc>";
         */
        String xmlString = "<impl:byFiscalCod 
xmlns:impl='http://javabean.websrv.napsi.eng.it'>"+
                           
"<ricercaIndividuo><codiceFiscale>XXXXXXXXXXXXX</codiceFiscale>"+
                           "</ricercaIndividuo></impl:byFiscalCod>";
        System.out.println( xmlString );
        SimpleAxisClient client = new SimpleAxisClient();
        Call miaCall = client.getCall(
                
"http://localhost:8082/ServicePublisher/services/Interaction","byFiscalCode";);
        Document doc = XMLUtils.newDocument(new 
java.io.ByteArrayInputStream(xmlString.getBytes()));
        System.out.println("doc.getDocumentElement(): " +
                           doc.getDocumentElement().getNodeName());
        Vector result = (Vector) miaCall.invoke
                        (new SOAPBodyElement[] {new SOAPBodyElement(doc.
                getDocumentElement())});
        SOAPBodyElement sbe = (SOAPBodyElement) result.get(0);

        System.out.println( "Ottenuto: "+ XMLUtils.DocumentToString( 
sbe.getAsDocument() ) );
    }
}

As you can see i have this file xml:

<impl:byFiscalCode xmlns:impl='http://javabean.websrv.napsi.eng.it'>
  <ricercaIndividuo>
          <codiceFiscale>XXXXXXXXXXXXX</codiceFiscale>
  </ricercaIndividuo>
</impl:byFiscalCode>

Now by doing so the method is called... but the document that it receives is 
the file xml that i have showed before; i'ld like that the document that the 
operation byFiscalCode accepts is
  <ricercaIndividuo>
          <codiceFiscale>XXXXXXXXXXXXX</codiceFiscale>
  </ricercaIndividuo>

How can i do?
If i must insert the operation name in the xml ( that is: <impl:byFiscalCode ) 
why must i use the

setOperation(new QName(endpoint, operation), operation) method of Call object?
Thanks to all




____________________________________________________________
6X velocizzare la tua navigazione a 56k? 6X Web Accelerator di Libero!
Scaricalo su INTERNET GRATIS 6X http://www.libero.it


Reply via email to