dev@jax-ws.java.net

Re: SOAPFault headers? (and SOAPFault in general)

From: Arun Gupta <Arun.Gupta_at_Sun.COM>
Date: Fri, 22 Dec 2006 13:31:25 -0800

Further update ...

If I create Dispatch with WSDL, then wsdlModel is not null and all
WS-Addressing headers are populated correctly. Here is the code that
worked for me:

-- cut here --
     public void testCustomFault() throws Exception {
         SOAPFault fault = SOAPFactory.newInstance().createFault("custom
fault from client", SOAPConstants.SOAP_SENDER_FAULT);

         InputStream is =
getClass().getClassLoader().getResourceAsStream("wsa/fromwsdl/custom/config/AddNumbers.wsdl");
         assertNotNull("WSDL cannot be read", is);
         ArrayList<Element> metadata = new ArrayList<Element>();
         metadata.add((Element)DOMUtil.createDOMNode(is).getFirstChild());

         WSEndpointReference to = new
WSEndpointReference(AddressingVersion.W3C,
                 getAddress(),
                 SERVICE_QNAME,
                 PORT_QNAME,
                 PORT_TYPE_QNAME,
                 metadata,
                 getWsdlAddress(),
                 null);

         Service service = Service.create(new URL(getWsdlAddress()),
SERVICE_QNAME);
// service.addPort(PORT_QNAME, SOAPBinding.SOAP11HTTP_BINDING,
getAddress());
         OneWayFeature owf = new OneWayFeature();
         owf.setRelatesToID("uuid:foobar");
         Dispatch<Source> dispatch = service.createDispatch(to.toSpec(),
Source.class,
 
Service.Mode.PAYLOAD,
                                                                 new
AddressingFeature(true, true),
                                                                 owf);
         try {
             dispatch.invokeOneWay(new DOMSource(fault));
         } catch (XMLStreamReaderException e) {
         }
     }
-- cut here --

Now wsdlModel is required for WS-Addressing to work. Do you have access
to the endpoint WSDL where the fault is dispatched to ? If yes, then try
creating the service this way and it should work. If not, then your
question gets morphed into:

How to create a Dispatch (w/o WSDL) such that WSDL model is correctly
populated ?

HTH,
-Arun

Arun Gupta wrote:
> Ryan,
>
> I have some information on this issue.
>
> Somehow the wsdlModel in the created Dispatch is null and the change
> made in [1] is causing WS-Addressing not to be enabled, even though all
> the features are set correctly on the client side. That's why no
> WS-Addressing headers are generated.
>
> I've added a test in our workspace (wsa.fromwsdl.custom.testCustomFault)
> for this condition. I'll continue digging for more information and keep
> you updated.
>
> Can you please file an issue on Issue Tracker though ?
>
> [1]
> http://fisheye5.cenqua.com/browse/jax-ws-sources/jaxws-ri/rt/src/com/sun/xml/ws/api/pipe/ClientTubeAssemblerContext.java?r1=1.1.2.14&r2=1.1.2.15
>
>
> Thanks,
> -Arun
>
>> <?xml version="1.0" ?>
>> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
>> <S:Header>
>> <jaxws:objectId xmlns:jaxws="http://jax-ws.dev.java.net/xml/ns/"
>> xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">305d682b-f1fb-4b8f-936d-a4805835b34f</jaxws:objectId>
>>
>> </S:Header>
>> <S:Body>
>> <SOAP-ENV:Fault
>> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>> <faultcode
>> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:wscoor="http://schemas.xmlsoap.org/ws/2004/10/wscoor">wscoor:InvalidParameters</faultcode>
>>
>> <faultstring xml:lang="en">The message contained invalid
>> parameters and could not be processed: foo</faultstring>
>> </SOAP-ENV:Fault>
>> </S:Body>
>> </S:Envelope>
>>
>>
>> public static void sendFault(@Nullable WSEndpointReference faultTo,
>> @NotNull EndpointReference replyTo,
>> @NotNull SOAPFault fault, String msgID) {
>> WSEndpointReference to = faultTo != null ? faultTo : new
>> WSEndpointReference(replyTo);
>>
>> WSService s = WSService.create();
>> final QName port = new QName("foo", "bar");
>> s.addPort(port, SOAPBinding.SOAP11HTTP_BINDING, to.getAddress());
>>
>> // one-way feature
>> OneWayFeature owf = new OneWayFeature();
>> owf.setRelatesToID(msgID);
>> // member submission addressing feature
>> WebServiceFeature af = new MemberSubmissionAddressingFeature(true);
>>
>> Dispatch<Source> d = s.createDispatch(port, to, Source.class,
>> Service.Mode.PAYLOAD, owf, af);
>> d.invokeOneWay(new DOMSource(fault));
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jax-ws.dev.java.net
>> For additional commands, e-mail: dev-help_at_jax-ws.dev.java.net
>>
>

-- 
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta