1 Reply Latest reply on Mar 11, 2010 5:28 AM by Alessio Soldano

    Problem in web service getting Exception: javax.xml.ws.soap.SOAPFaultException

    rinku GARG Newbie

      Hi Everybody,

       

      I am trying to develop a Secured Webservice with JBoss 5.1.0 and Java 1.5. I am able to deploy the server successfully, but when I run the client then Jboss Server throws the following exception:

       

       

      
      ***********************
      Create Web Service Client...
      Create Web Service...
      Call Web Service Operation...
      
      Exception in thread "main"
      
       
      
      javax.xml.ws.soap.SOAPFaultException: This service requires <wsse:Security>, which is 
      missing.
      
      
       
      
      
      SOAP11Fault.java:188)
      
      
       
      
      
      SOAPFaultBuilder.java:108)
      
      
       
      
      
      SyncMethodHandler.java:119)
      
      
       
      
      
      SyncMethodHandler.java:89)
      
      
       
      
      
      SEIStub.java:118)
      at $Proxy26.toCelsius(Unknown Source)
      at 
      com.bean.ws.temperature.clientsample.ClientSample.main(ClientSample.java)
      
      
      
      


       

       

      ==========================================================================================================

       

      My source code is as given below:

       

      1. TempWsBean.java

      package 
      com.bean.ws.temperature;
      import 
      javax.jws.WebMethod;
      import javax.jws.WebParam;
      import 
      javax.jws.WebResult;
      import javax.jws.WebService;
      import 
      javax.xml.ws.RequestWrapper;
      import 
      javax.xml.ws.ResponseWrapper;
      @WebService(name 
      = "TempWsBean", targetNamespace = "http://temperature.ws.bean.com")
      public 
      interface TempWsBean 
      {
          
      @WebMethod(action = "http://temperature.ws.bean.com/toCelsius")
          
      @WebResult(name = "returnFahrenheit", targetNamespace = "")
          
      @RequestWrapper(localName = "toCelsius", targetNamespace = "http://temperature.ws.bean.com", 
      className = "com.bean.ws.temperature.ToCelsius")
          
      @ResponseWrapper(localName = "toCelsiusResponse", targetNamespace = "http://temperature.ws.bean.com", 
      className = 
      "com.bean.ws.temperature.ToCelsiusResponse")
          
      public float toCelsius(
              @WebParam(name = "fahrenheit", 
      targetNamespace = "")
              float 
      fahrenheit);
          
      @WebMethod(action = "http://temperature.ws.bean.com/toFahrenheit")
          
      @WebResult(name = "returnCelsius", targetNamespace = "")
          
      @RequestWrapper(localName = "toFahrenheit", targetNamespace = "http://temperature.ws.bean.com", 
      className = "com.bean.ws.temperature.ToFahrenheit")
          
      @ResponseWrapper(localName = "toFahrenheitResponse", targetNamespace = "http://temperature.ws.bean.com", 
      className = 
      "com.bean.ws.temperature.ToFahrenheitResponse")
          
      public float toFahrenheit(
              @WebParam(name = "celsius", 
      targetNamespace = "")
              float 
      celsius);
      }
      
      
      


      2. TempWsBeanService.java

      package 
      com.bean.ws.temperature;
      import 
      java.net.MalformedURLException;
      import java.net.URL;
      import 
      java.util.logging.Logger;
      import 
      javax.xml.namespace.QName;
      import javax.xml.ws.Service;
      import 
      javax.xml.ws.WebEndpoint;
      import 
      javax.xml.ws.WebServiceClient;
      import 
      org.jboss.ws.annotation.EndpointConfig;
      @WebServiceClient(name 
      = "TempWsBeanService", targetNamespace = "http://temperature.ws.bean.com", 
      wsdlLocation = 
      "file:/F:/NewGelileoWorkspace/SecureWebService/wsdl/TempWsBeanService.wsdl")
      @EndpointConfig(configName 
      ="Standard WSSecurity Endpoint")
      public class TempWsBeanService
          
      extends 
      Service
      {
          
      private final static URL TEMPWSBEANSERVICE_WSDL_LOCATION;
          private final 
      static Logger logger = 
      Logger.getLogger(com.bean.ws.temperature.TempWsBeanService.class.getName());
          
      static {
              URL url = null;
              try {
                  URL 
      baseUrl;
                  baseUrl = 
      com.bean.ws.temperature.TempWsBeanService.class.getResource(".");
                  
      url = new URL(baseUrl, 
      "file:/F:/NewGelileoWorkspace/SecureWebService/wsdl/TempWsBeanService.wsdl");
              
      } catch (MalformedURLException e) {
                  logger.warning("Failed to 
      create URL for the wsdl Location: 
      'file:/F:/NewGelileoWorkspace/SecureWebService/wsdl/TempWsBeanService.wsdl', 
      retrying as a local file");
                  
      logger.warning(e.getMessage());
              }
              
      TEMPWSBEANSERVICE_WSDL_LOCATION = url;
          
      }
          
      public TempWsBeanService(URL wsdlLocation, QName serviceName) {
              
      super(wsdlLocation, serviceName);
          
      }
          
      public TempWsBeanService() {
              super(TEMPWSBEANSERVICE_WSDL_LOCATION, 
      new QName("http://temperature.ws.bean.com", 
      "TempWsBeanService"));
          
      }
          
      @WebEndpoint(name = "TempWsBeanPort")
          public TempWsBean 
      getTempWsBeanPort() {
              return super.getPort(new QName("http://temperature.ws.bean.com", 
      "TempWsBeanPort"), TempWsBean.class);
          
      }
      }
      
      
      

       

      3. ClientSample.java

       

      package 
      com.bean.ws.temperature.clientsample;
      import 
      java.io.File;
      import java.net.MalformedURLException;
      import 
      java.net.URL;
      import 
      org.jboss.ws.core.ConfigProvider;
      import 
      com.bean.ws.temperature.TempWsBean;
      import 
      com.bean.ws.temperature.TempWsBeanService;
      public 
      class ClientSample 
      {
      public 
      static void main(String[] args) 
      {
         
      System.out.println("***********************");
               
      System.out.println("Create Web Service Client...");
               
      TempWsBeanService service1 = new TempWsBeanService();
               
      System.out.println("Create Web Service...");
               TempWsBean port1 = 
      service1.getTempWsBeanPort();
               
      System.out.println("Call Web Service Operation...");
               
      System.out.println("Server said: " + port1.toCelsius(98.6f));
               
      //Please input the parameters instead of 'null' for the upper 
      method!
      
               System.out.println("Server said: " + 
      port1.toFahrenheit(37f));
               //Please input the parameters instead of 
      'null' for the upper method!
      
               
      System.out.println("***********************");
               
      System.out.println("Call Over!");
      }
      }
      
      
      

       

      4.jboss-wsse-client.java file is in META-INF folder

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-ws-security xmlns="http://www.jboss.com/ws-security/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.jboss.com/ws-security/config
      http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
      <key-store-file>META-INF/client.keystore</key-store-file>
      <key-store-type>jks</key-store-type>
      <key-store-password>client.keystore</key-store-password>
      <trust-store-file>META-INF/client.truststore</trust-store-file>
      <trust-store-type>jks</trust-store-type>
      <trust-store-password>client.keystore</trust-store-password>
      <key-passwords>
        
      <key-password alias="server" password="server.keystore" 
      />
      </key-passwords>
      <config>
        <sign alias="client" 
      type="x509v3" />
        <encrypt type="x509v3" alias="server" />
        
      <requires>
        <signature />
         <encryption />
        
      </requires>
      </config>
      </jboss-ws-security>
      
      
      

       

      5. standard-jaxws-client-config.xml file is in META-INF folder

       

      <?xml version="1.0" 
      encoding="UTF-8"?>
      <jaxws-config 
      xmlns="urn:jboss:jaxws-config:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:javaee="http://java.sun.com/xml/ns/javaee"
        
      xsi:schemaLocation="urn:jboss:jaxws-config:2.0 
      schema/jaxws-config_2_0.xsd">
        
      <client-config>
          <config-name>Standard WSSecurity 
      Client</config-name>
          <post-handler-chains>
            
      <javaee:handler-chain>
             <!-- 
      <javaee:protocol-bindings>##SOAP11_HTTP 
      ##SOAP11_HTTP_MTOM</javaee:protocol-bindings> -->
             
      <javaee:protocol-bindings>##SOAP11_HTTP</javaee:protocol-bindings>
             
      <javaee:handler>
                
      <javaee:handler-name>WSSecurityHandlerOutbound</javaee:handler-name>
                
      <javaee:handler-class>org.jboss.ws.extensions.security.jaxws.WSSecurityHandlerClient</javaee:handler-class>
              
      </javaee:handler>
            </javaee:handler-chain>
          
      </post-handler-chains>
        
      </client-config>
      
      </jaxws-config>
      
      
      

       

      6. jboss-web.xml file is in WEB-INF folder

      <?xml version="1.0" 
      encoding="UTF-8"?>
      <jboss-web>
      <security-domain>JBossWS</security-domain>
      </jboss-web>
      
      
      


      7. jboss-wsse-server.xml file is in WEB-INF folder

      <?xml version="1.0" encoding="UTF-8"?>
      <jboss-ws-security xmlns="http://www.jboss.com/ws-security/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.jboss.com/ws-security/config
      http://www.jboss.com/ws-security/schema/jboss-ws-security_1_0.xsd">
      <key-store-file>WEB-INF/server.keystore</key-store-file>
      <key-store-type>jks</key-store-type>
      <key-store-password>server.keystore</key-store-password>
      <trust-store-file>WEB-INF/server.truststore</trust-store-file>
      <trust-store-type>jks</trust-store-type>
      <trust-store-password>server.keystore</trust-store-password>
      <key-passwords>
        
      <key-password alias="server" password="server.keystore" 
      />
      </key-passwords>
      <config>
        <sign type = "x509v3" 
      alias="server"/>
        <encrypt type ="x509v3" alias="client" />
        
      <requires>
         <signature />
         <encryption />
        
      </requires>
      </config>
      </jboss-ws-security>
      
      
      

       

      Here is TempWsServiceBean.wsdl file

       

       

      <xml version="1.0" encoding="UTF-8"?> 
      
      
       
      
      definitions name='TempWsBeanService' targetNamespace='http://temperature.ws.bean.com' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://temperature.ws.bean.com' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
      
       
      <types>
      
       
      <xs:schema targetNamespace='http://temperature.ws.bean.com' version='1.0' xmlns:tns='http://temperature.ws.bean.com' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
      
       
      <xs:element 
      name='toCelsius' type='tns:toCelsius'/>
      
       
      <xs:element 
      name='toCelsiusResponse' type='tns:toCelsiusResponse'/>
      
       
      <xs:element 
      name='toFahrenheit' type='tns:toFahrenheit'/>
      
       
      <xs:element 
      name='toFahrenheitResponse' type='tns:toFahrenheitResponse'/>
      
       
      <xs:complexType 
      name='toCelsius'>
      
       
      <xs:sequence>
      
       
      <xs:element 
      name='fahrenheit' type='xs:float'/>
      
       
      </xs:sequence>
      
       
      </xs:complexType>
      
       
      <xs:complexType 
      name='toCelsiusResponse'>
      
       
      <xs:sequence>
      
       
      <xs:element 
      name='returnFahrenheit' type='xs:float'/>
      
       
      </xs:sequence>
      
       
      </xs:complexType>
      
       
      <xs:complexType 
      name='toFahrenheit'>
      
       
      <xs:sequence>
      
       
      <xs:element 
      name='celsius' type='xs:float'/>
      
       
      </xs:sequence>
      
       
      </xs:complexType>
      
       
      <xs:complexType 
      name='toFahrenheitResponse'>
      
       
      <xs:sequence>
      
       
      <xs:element 
      name='returnCelsius' type='xs:float'/>
      
       
      </xs:sequence>
      
       
      </xs:complexType>
      
       
      </xs:schema>
      
       
      </types>
      
       
      <message name='TempWsBean_toCelsius'>
      
       
      <part element='tns:toCelsius' name='toCelsius'/>
      
       
      </message>
      
       
      <message name='TempWsBean_toCelsiusResponse'>
      
       
      <part element='tns:toCelsiusResponse' name='toCelsiusResponse'/>
      
       
      </message>
      
       
      <message name='TempWsBean_toFahrenheit'>
      
       
      <part element='tns:toFahrenheit' name='toFahrenheit'/>
      
       
      </message>
      
       
      <message name='TempWsBean_toFahrenheitResponse'>
      
       
      <part element='tns:toFahrenheitResponse' name='toFahrenheitResponse'/>
      
       
      </message>
      
       
      <portType name='TempWsBean'>
      
       
      <operation name='toCelsius' parameterOrder='toCelsius'>
      
       
      <input message='tns:TempWsBean_toCelsius'/>
      
       
      <output message='tns:TempWsBean_toCelsiusResponse'/>
      
       
      </operation>
      
       
      <operation name='toFahrenheit' parameterOrder='toFahrenheit'>
      
       
      <input message='tns:TempWsBean_toFahrenheit'/>
      
       
      <output message='tns:TempWsBean_toFahrenheitResponse'/>
      
       
      </operation>
      
       
      </portType>
      
       
      <binding name='TempWsBeanBinding' type='tns:TempWsBean'>
      
       
      <soap:binding 
      style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
      
       
      <operation name='toCelsius'>
      
       
      <soap:operation 
      soapAction='http://temperature.ws.bean.com/toCelsius'/>
      
       
      <input>
      
       
      <soap:body use='literal'/>
      
       
      </input>
      
       
      <output>
      
       
      <soap:body use='literal'/>
      
       
      </output>
      
       
      </operation>
      
       
      <operation name='toFahrenheit'>
      
       
      <soap:operation 
      soapAction='http://temperature.ws.bean.com/toFahrenheit'/>
      
       
      <input>
      
       
      <soap:body use='literal'/>
      
       
      </input>
      
       
      <output>
      
       
      <soap:body use='literal'/>
      
       
      </output>
      
       
      </operation>
      
       
      </binding>
      
       
      <service name='TempWsBeanService'>
      
       
      <port binding='tns:TempWsBeanBinding' name='TempWsBeanPort'>
      
       
      <soap:address 
      location='http://127.0.0.1:8080/TempWsAnnotations/TempWsBean'/>
      
       
      </port>
      
       
      
      <definitions>
      
      </service> 
      
      
       
      

       

       

       

      Can Anybody help on this please..

       

      Regards

      Rinku Garg