You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Håkon Sagehaug <Ha...@bccs.uib.no> on 2009/04/20 11:01:36 UTC

Ws-policy and handling exceptions

Hi all

I've got a service with a method that looks like this in the WSDL

<operation name="SayHi">
            <wsp:Policy xmlns:wsp="
http://schemas.xmlsoap.org/ws/2004/09/policy"
                xmlns:sp="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" Id="UTOverTransport">
                <wsp:ExactlyOne>
                    <wsp:All>
                        <sp:TransportBinding xmlns:sp="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                            <wsp:Policy>
                                <sp:HttpsToken
RequireClientCertificate="false"/>
                                <sp:IncludeTimestamp/>
                            </wsp:Policy>
                        </sp:TransportBinding>
                        <sp:SupportingTokens xmlns:sp="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
                            <wsp:Policy>
                                <sp:UsernameToken sp:IncludeToken="
http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient
"/>
                            </wsp:Policy>
                        </sp:SupportingTokens>
                    </wsp:All>
                </wsp:ExactlyOne>
        </wsp:Policy>
            <input message="tns:SayHiRequestMsg">
            </input>
            <output message="tns:SayHiResponseMsg">
            </output>
            <fault name="SayFault" message="tns:EchoFaultMessage" />
        </operation>

It requires a username token for it ti be executed, if something happens in
the execution a fault is thrown. The implementation looks like this

if (sayHi2.getSayHiElm().getHiSec().equals("fault")) {
            EchoFaultMessage faultM = new EchoFaultMessage();
            EchoFault fault = new EchoFault();

            fault.setFaultMessage("fault");
            faultM.setFaultMessage(fault);

            throw faultM;

        } else {

            SayHiResponse resp = new SayHiResponse();
            resp.setHiResponse("sfdfdd");

            return resp;

        }

a reqest that would generate a fault looks like this

<soapenv:Body>
      <sec:SayHi>
         <sec:SayHiElm>
            <type:HiSec>fault</type:HiSec>
         </sec:SayHiElm>
      </sec:SayHi>
   </soapenv:Body>


If I call the method and no fault is thrown everything works fine, but if I
call the method and a exception is thrown I get this error message in my log
at the server side.

[INFO] org.apache.axis2.AxisFault: Error in extracting message properties


The strange thing is, that if I remove the policy from wsdl and generate new
code, all works both when an exception is thrown and normal execution.

I generate my code using the maven axis2 codegen plugin, I tried both
generating code using axis2 1.3 and 1.4, but I got the same result. Using
adb as my databinding.

Has anyone experienced anything similar as this??

cheers, håkon
-- 
Håkon Sagehaug, Scientific Programmer
Parallab, Bergen Center for Computational Science (BCCS)
UNIFOB AS (University of Bergen Research Company)