package tutorial.sample9;

import javax.xml.soap.SOAPFactory;
import javax.xml.soap.Detail;
import javax.xml.soap.SOAPException;

import javax.xml.namespace.QName;
import javax.xml.rpc.soap.SOAPFaultException;


public class HelloWorldService{

  public void helloSOAPFault(){

    Detail detail = null; 

    try{
      detail = SOAPFactory.newInstance().createDetail();
      detail.addChildElement( "MyDetails" ).addTextNode( "failed" );
    }catch( SOAPException e ){
      e.printStackTrace();
    }

    throw new SOAPFaultException( 
        new QName( "http://tutorial/sample9/fault", "ServerFailed" ),
        "helloSOAPFault method failed",
        "http://foo/bar/baz/",
        detail );
  }

  public void helloCustomFault() throws HelloWorldException{
    throw new HelloWorldException( "This is my error message, " +
        "client should get this" );
  }
}

