Hello Brian,
where do I set the SOAP action on the server side (pls. remember that
the service runs into an embedded jetty/SimpleHTTPServer instance)?
Thanks,
Michele
On Sat, 2007-10-13 at 12:16 +0100, Brian De Pradine wrote:
>
> Hello Michele,
>
> It appears that the request cannot be dispatched based solely on the
> content of the SOAP body. Try setting the SOAPAction explicitly before
> you call dispatch.invoke()
>
> Map<String, Object> map = dispatch.getRequestContext();
> map.put(BindingProvider.SOAPACTION_USE_PROPERTY,
> Boolean.TRUE);
> map.put(BindingProvider.SOAPACTION_URI_PROPERTY, "...");
>
> Cheers
>
> Brian DePradine
> Web Services Development
> IBM Hursley
> External +44 (0) 1962 816319 Internal 246319
>
> If you can't find the time to do it right the first time, where will
> you find the time to do it again?
>
>
> Michele Mazzucco <[EMAIL PROTECTED]> wrote on 12/10/2007
> 10:22:35:
>
> > Nick.
> >
> > thanks, but I can't get it working.
> >
> > Here is the service (it's like SOAP12Provider, but without
> > dependencies):
> >
> > package service.jaxws;
> >
> > import javax.xml.ws.BindingType;
> > import javax.xml.ws.Provider;
> > import javax.xml.ws.WebServiceProvider;
> > import javax.xml.ws.soap.SOAPBinding;
> >
> > /**
> > * A Provider<String> implementation used to test sending and
> > * receiving SOAP 1.2 messages.
> > */
> > @WebServiceProvider()
> > @BindingType(SOAPBinding.SOAP12HTTP_BINDING)
> > public class SOAP12Provider implements Provider<String> {
> >
> > private static final String sampleResponse =
> > "<test:echoStringResponse xmlns:test=
> > \"http://org/apache/axis2/jaxws/test/SOAP12\">" +
> > "<test:output>SAMPLE REQUEST MESSAGE</test:output>" +
> > "</test:echoStringResponse>";
> >
> > /*
> > * @see javax.xml.ws.Provider#invoke(java.lang.Object)
> > */
> > public String invoke(String obj) {
> > System.out.printf("Received >>> %s\n", obj);
> > return sampleResponse;
> > }
> >
> > }
> >
> >
> > which runs into an embedded axis2 instance:
> >
> > import java.util.HashMap;
> > import java.util.Map;
> >
> >
> > import org.apache.axis2.AxisFault;
> > import org.apache.axis2.context.ConfigurationContext;
> > import org.apache.axis2.context.ConfigurationContextFactory;
> > import org.apache.axis2.description.AxisService;
> > import org.apache.axis2.transport.http.SimpleHTTPServer;
> > import org.apache.log4j.BasicConfigurator;
> >
> > import service.jaxws.SOAP12Provider;
> >
> > /**
> > * <a href="http://wso2.org/library/83">How do I Embed
> SimpleHTTPServer
> > in My
> > * Application and Deploy a POJO?</a>
> > *
> > */
> > public class EmbeddedAxis2Server {
> >
> > static {
> > BasicConfigurator.configure();
> > }
> >
> > /**
> > * @param args
> > */
> > public static void main(String[] args) throws AxisFault {
> > ConfigurationContext context = ConfigurationContextFactory
> > .createConfigurationContextFromFileSystem(null,
> null);
> >
> > Map<String, String> map = new HashMap<String, String>(1);
> > map.put("http://www.w3.org/2004/08/wsdl/in-out",
> > "org.apache.axis2.jaxws.server.JAXWSMessageReceiver");
> >
> > AxisService echoJaxWs =
> > AxisService.createService(SOAP12Provider.class.getName(),
> > context.getAxisConfiguration(), map,
> > "http://org/apache/axis2/jaxws/test/SOAP12",
> > "http://org/apache/axis2/jaxws/test/SOAP12",
> > Thread.currentThread().getContextClassLoader());
> > context.getAxisConfiguration().addService(echoJaxWs);
> >
> > SimpleHTTPServer server = new SimpleHTTPServer(context,
> 8080);
> > server.start();
> > }
> >
> > }
> >
> >
> > The client is SOAP12Dispatch + the main method
> >
> > import java.io.ByteArrayInputStream;
> > import java.io.ByteArrayOutputStream;
> >
> > import javax.xml.ws.Service.Mode;
> > import javax.xml.namespace.QName;
> > import javax.xml.transform.Source;
> > import javax.xml.transform.Transformer;
> > import javax.xml.transform.TransformerFactory;
> > import javax.xml.transform.stream.StreamResult;
> > import javax.xml.transform.stream.StreamSource;
> > import javax.xml.ws.Dispatch;
> > import javax.xml.ws.Service;
> > import javax.xml.ws.soap.SOAPBinding;
> > import javax.xml.ws.soap.SOAPFaultException;
> >
> > import org.apache.log4j.BasicConfigurator;
> >
> > public class SOAP12Dispatch {
> >
> > private static final QName QNAME_SERVICE = new QName(
> > "http://org/apache/axis2/jaxws/test/SOAP12",
> "SOAP12Service");
> >
> > private static final QName QNAME_PORT = new QName(
> > "http://org/apache/axis2/jaxws/test/SOAP12", "SOAP12Port");
> >
> > private static final String URL_ENDPOINT =
> > "http://localhost:8080/axis2/services/SOAP12Provider";
> >
> > private static final String sampleRequest = "<test:echoString
> > xmlns:test=\"http://org/apache/axis2/jaxws/test/SOAP12\">"
> > + "<test:input>SAMPLE REQUEST MESSAGE</test:input>" +
> > "</test:echoString>";
> >
> > private static final String sampleEnvelopeHead =
> "<soapenv:Envelope
> > xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">"
> > + "<soapenv:Header /><soapenv:Body>";
> >
> > private static final String sampleEnvelopeHead_MustUnderstand =
> > "<soapenv:Envelope xmlns:soapenv=
> > \"http://www.w3.org/2003/05/soap-envelope\">"
> > + "<soapenv:Header>"
> > + "<soapenv:codeHeaderSOAP12 soapenv:mustUnderstand=
> \"true
> > \">"
> > + "<code>default</code>"
> > + "</soapenv:codeHeaderSOAP12>"
> > + "</soapenv:Header>" + "<soapenv:Body>";
> >
> > private static final String sampleEnvelopeTail =
> > "</soapenv:Body></soapenv:Envelope>";
> >
> > private static final String sampleEnvelope = sampleEnvelopeHead
> +
> > sampleRequest
> > + sampleEnvelopeTail;
> >
> > private static final String sampleEnvelope_MustUnderstand =
> > sampleEnvelopeHead_MustUnderstand
> > + sampleRequest + sampleEnvelopeTail;
> >
> >
> > /**
> > * Test sending a SOAP 1.2 request in PAYLOAD mode
> > */
> > public void testSOAP12DispatchPayloadMode() throws Exception {
> > // Create the JAX-WS client needed to send the request
> > Service service = Service.create(QNAME_SERVICE);
> > service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING,
> > URL_ENDPOINT);
> > Dispatch<Source> dispatch = service.createDispatch(
> > QNAME_PORT, Source.class, Mode.PAYLOAD);
> >
> > // Create the Source object with the payload contents.
> Since
> > // we're in PAYLOAD mode, we don't have to worry about the
> > envelope.
> > byte[] bytes = sampleRequest.getBytes();
> > ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
> > StreamSource request = new StreamSource(bais);
> >
> > // Send the SOAP 1.2 request
> > Source response = dispatch.invoke(request);
> >
> > // Convert the response to a more consumable format
> > ByteArrayOutputStream baos = new ByteArrayOutputStream();
> > StreamResult result = new StreamResult(baos);
> >
> > TransformerFactory factory =
> TransformerFactory.newInstance();
> > Transformer trans = factory.newTransformer();
> > trans.transform(response, result);
> >
> > // Check to make sure the contents are correct. Again,
> since
> > we're
> > // in PAYLOAD mode, we shouldn't have anything related to
> the
> > envelope
> > // in the return, just the contents of the Body.
> > String responseText = baos.toString();
> > if (responseText.contains("soap")) {
> > throw new IllegalStateException("the response contains
> > 'soap'");
> > }
> > if (responseText.contains("Body")) {
> > throw new IllegalStateException("the response contains
> > 'Body'");
> > }
> > if (responseText.contains("Envelope")) {
> > throw new IllegalStateException("the response contains
> > 'Envelope'");
> > }
> > if (responseText.contains("echoStringResponse")) {
> > throw new IllegalStateException("the response contains
> > 'echoStringResponse'");
> > }
> > }
> >
> > /**
> > * Test sending a SOAP 1.2 request in MESSAGE mode
> > */
> > public void testSOAP12DispatchMessageMode() throws Exception {
> > // Create the JAX-WS client needed to send the request
> > Service service = Service.create(QNAME_SERVICE);
> > service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING,
> > URL_ENDPOINT);
> > Dispatch<Source> dispatch = service.createDispatch(
> > QNAME_PORT, Source.class, Mode.MESSAGE);
> >
> > // Create the Source object with the message contents.
> Since
> > // we're in MESSAGE mode, we'll need to make sure we create
> this
> > // with the right protocol.
> > byte[] bytes = sampleEnvelope.getBytes();
> > ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
> > StreamSource request = new StreamSource(bais);
> >
> > Source response = dispatch.invoke(request);
> >
> > // Convert the response to a more consumable format
> > ByteArrayOutputStream baos = new ByteArrayOutputStream();
> > StreamResult result = new StreamResult(baos);
> >
> > TransformerFactory factory =
> TransformerFactory.newInstance();
> > Transformer trans = factory.newTransformer();
> > trans.transform(response, result);
> >
> > // Check to make sure the contents of the message are
> correct
> > String responseText = baos.toString();
> >
> > if (! responseText.contains("soap")) {
> > throw new IllegalStateException("the response does not
> > contain 'soap'");
> > }
> > if (! responseText.contains("Body")) {
> > throw new IllegalStateException("the response does not
> > contain 'Body'");
> > }
> > if (! responseText.contains("Envelope")) {
> > throw new IllegalStateException("the response does not
> > contain 'Envelope'");
> > }
> > if (! responseText.contains("echoStringResponse")) {
> > throw new IllegalStateException("the response does not
> > contain 'echoStringResponse'");
> > }
> >
> > // Check to make sure the message returned had the right
> > protocol version
> > // TODO: Need to determine whether or not we should be using
> the
> > hard
> > // coded URLs here, or whether we should be using a constant
> for
> > the
> > // purposes of the test.
> > if (!
> > responseText.contains("http://www.w3.org/2003/05/soap-envelope")) {
> > throw new IllegalStateException("the response does not
> > contain 'http://www.w3.org/2003/05/soap-envelope'");
> > }
> > if (!
> > responseText.contains("http://schemas.xmlsoap.org/soap/envelop")) {
> > throw new IllegalStateException("the response does not
> > contain 'http://schemas.xmlsoap.org/soap/envelop'");
> > }
> > }
> >
> > /**
> > * Test sending a SOAP 1.2 request in MESSAGE mode
> > */
> > public void testSOAP12DispatchMessageMode_MustUnderstand()
> throws
> > Exception {
> > // Create the JAX-WS client needed to send the request
> > Service service = Service.create(QNAME_SERVICE);
> > service.addPort(QNAME_PORT, SOAPBinding.SOAP12HTTP_BINDING,
> > URL_ENDPOINT);
> > Dispatch<Source> dispatch = service.createDispatch(
> > QNAME_PORT, Source.class, Mode.MESSAGE);
> >
> > // Create the Source object with the message contents.
> Since
> > // we're in MESSAGE mode, we'll need to make sure we create
> this
> > // with the right protocol.
> > byte[] bytes = sampleEnvelope_MustUnderstand.getBytes();
> > ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
> > StreamSource request = new StreamSource(bais);
> >
> > SOAPFaultException e = null;
> > try {
> > @SuppressWarnings("unused")
> > Source response = dispatch.invoke(request);
> > throw new RuntimeException("We should have an exception,
> but
> > none was thrown.", e);
> > } catch (SOAPFaultException ex) {
> > System.out.println("ok, exception expected");
> > e = ex;
> >
> >
> > if (!
> >
> "MustUnderstand".equals(e.getFault().getFaultCodeAsQName().getLocalPart())) {
> > throw new RuntimeException("FaultCode should be
> > \"MustUnderstand\"");
> > }
> > }
> > }
> >
> >
> > /**
> > * @param args
> > * @throws Exception
> > */
> > public static void main(String[] args) throws Exception {
> > BasicConfigurator.configure();
> > SOAP12Dispatch dispatch = new SOAP12Dispatch();
> > dispatch.testSOAP12DispatchPayloadMode();
> > }
> >
> > }
> >
> >
> >
> > When I run it I get this error on the client side, it doesn't matter
> > whether the endpoint is
> > http://localhost:8080/axis2/services/SOAP12Provider
> > or
> > http://localhost:8080/axis2/services/SOAP12ProviderService
> >
> >
> > 4894 [main] DEBUG
> > org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl -
> Converting
> > OMElement to an SAAJ SOAPElement
> > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: The
> > endpoint reference (EPR) for the Operation not found is
> > 127.0.0.1/axis2/services/SOAP12Provider and the WSA Action =
> > urn:anonOutInOp
> > at
> > org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.
> > createSystemException(MethodMarshallerUtils.java:1192)
> > at
> > org.apache.axis2.jaxws.client.dispatch.BaseDispatch.
> > getFaultResponse(BaseDispatch.java:405)
> > at
> > org.apache.axis2.jaxws.client.dispatch.BaseDispatch.
> > invoke(BaseDispatch.java:170)
> > at
> > service.jaxws.SOAP12Dispatch.
> > testSOAP12DispatchPayloadMode(SOAP12Dispatch.java:81)
> > at service.jaxws.SOAP12Dispatch.main(SOAP12Dispatch.java:205)
> >
> >
> >
> > Any idea?
> >
> > Michele
> >
> > On Thu, 2007-10-11 at 13:03 -0500, Nicholas L Gallardo wrote:
> > > There are also a number of examples in the JAX-WS test bucket.
> > >
> > > Look at org.apache.axis2.jaxws.dispatch.*
> > >
> > > -Nick
> > >
> > > Inactive hide details for Brian De Pradine
> <[EMAIL PROTECTED]>Brian
> > > De Pradine <[EMAIL PROTECTED]>
> > >
> > >
> > > Brian De Pradine
> <[EMAIL PROTECTED]>
> > >
> > > 10/11/2007 07:02 AM
> > > Please respond to
> > > [email protected]
> > >
> > >
> > > To
> > >
> > > [email protected]
> > >
> > > cc
> > >
> > >
> > >
> > > Subject
> > >
> > > Re: [Axis2]
> > > JAX-WS & working
> > > at xml level on
> > > the client side
> > >
> > >
> > >
> > >
> > > Hello Michele,
> > >
> > > You can find info about dispatch clients at [1].
> > >
> > > [1] https://jax-ws.dev.java.net/nonav/2.1.2/docs/dispatch.html
> > >
> > > Cheers
> > >
> > > Brian DePradine
> > > Web Services Development
> > > IBM Hursley
> > > External +44 (0) 1962 816319 Internal 246319
> > >
> > > If you can't find the time to do it right the first time, where
> will
> > > you find the time to do it again?
> > >
> > >
> > > Michele Mazzucco <[EMAIL PROTECTED]> wrote on 11/10/2007
> > > 12:47:39:
> > >
> > > > Hi Brian,
> > > >
> > > > what do you mean?, do you have any example?
> > > >
> > > > Thanks,
> > > > Michele
> > > >
> > > > On Thu, 2007-10-11 at 12:45 +0100, Brian De Pradine wrote:
> > > > >
> > > > > Hello Michele,
> > > > >
> > > > > Try creating a dispatch client.
> > > > >
> > > > > Cheers
> > > > >
> > > > > Brian DePradine
> > > > > Web Services Development
> > > > > IBM Hursley
> > > > > External +44 (0) 1962 816319 Internal 246319
> > > > >
> > > > > If you can't find the time to do it right the first time,
> where
> > > will
> > > > > you find the time to do it again?
> > > > >
> > > > >
> > > > > Michele Mazzucco <[EMAIL PROTECTED]> wrote on
> 11/10/2007
> > > > > 10:57:35:
> > > > >
> > > > > > Hi all,
> > > > > >
> > > > > > I understand that by implementing the javax.xml.ws.Provider
> > > > > interface
> > > > > > it's possible to work at low level (i.e. to control the XML
> > > which is
> > > > > > sent back and forth).
> > > > > > Now, if I have a service which implements the Provider
> interface
> > > is
> > > > > > there any way to work at low level on the client side as
> well,
> > > that
> > > > > is
> > > > > > the same way as ServiceClient + RawXML.. msg. receivers +
> Axiom?
> > > > > >
> > > > > >
> > > > > > Thanks,
> > > > > > Michele
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > >
> ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > > For additional commands, e-mail:
> [EMAIL PROTECTED]
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> ______________________________________________________________________
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Unless stated otherwise above:
> > > > > IBM United Kingdom Limited - Registered in England and Wales
> with
> > > > > number 741598.
> > > > > Registered office: PO Box 41, North Harbour, Portsmouth,
> Hampshire
> > > PO6
> > > > > 3AU
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> ______________________________________________________________________
> > >
> > >
> > >
> > > Unless stated otherwise above:
> > > IBM United Kingdom Limited - Registered in England and Wales with
> > > number 741598.
> > > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire
> PO6
> > > 3AU
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
>
>
> ______________________________________________________________________
>
>
>
>
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with
> number 741598.
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
> 3AU
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]