0 Replies Latest reply on Dec 5, 2009 5:27 AM by slim Soltani dridi

    WebServices client not working - Cannot obtain wsdl service

    slim Soltani dridi Newbie

      Hi all,

      I don't know to do call at the web service frim Struts application.

      ActionForm

      package contrat;
      
      import javax.servlet.http.HttpServletRequest;
      
      import org.apache.struts.action.ActionErrors;
      import org.apache.struts.action.ActionMapping;
      
      public class ContratBean extends org.apache.struts.action.ActionForm {
      
       private String nameContrat;
       private String descriptionContrat;
       public String getNameContrat() {
       return nameContrat;
       }
      
       public void setNameContrat(String nameContrat) {
       this.nameContrat = nameContrat;
       }
      
       public String getDescriptionContrat() {
       return descriptionContrat;
       }
      
       public void setDescriptionContrat(String descriptionContrat) {
       this.descriptionContrat = descriptionContrat;
       }
      
       public String getTypeContrat() {
       return typeContrat;
       }
      
       public void setTypeContrat(String typeContrat) {
       this.typeContrat = typeContrat;
       }
      
       private String typeContrat;
      
      
       public ContratBean () {
       }
      
       public void reset(ActionMapping actionMapping, HttpServletRequest request) {
       // TODO: Write method body
       this.nameContrat="";
       this.descriptionContrat="";
       this.typeContrat="";
       }
      
       public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
       // TODO: Write method body
       ActionErrors errors = new ActionErrors();
       return errors;
       }
      
      
      }
      


      Action
      package contrat;
      
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      
      
      import org.apache.struts.action.ActionForm;
      import org.apache.struts.action.ActionForward;
      import org.apache.struts.action.ActionMapping;
      import contratwsmanager.WSManager;
      
      import contratwsmanager.WSManager;
      
      public class ContratFormAction extends org.apache.struts.action.Action {
      
       // Global Forwards
       public static final String GLOBAL_FORWARD_start = "start";
      
       // Local Forwards
       public static final String FORWARD_sucessContrat = "sucessContrat";
      
       public ContratFormAction() {
       }
      
       public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
       // TODO: Write method body
       WSManager wsmanager = null;
       ContratBean contratData = (ContratBean) (form);
       String test = "";
      
      
       try
       {
       wsmanager = new WSManager();
       test = wsmanager.WSManagerAddContrat();
       contratData.setNameContrat(test);
       }
       catch (Exception e) {
       // TODO: handle exception
       e.getStackTrace();
       }
       String nameContrat = contratData.getNameContrat();
       return mapping.findForward(FORWARD_sucessContrat);
       }
      }


      WSManager
      package contratwsmanager;
      
      import java.util.Vector;
      
      import org.apache.log4j.Category;
      
      import javax.xml.soap.*;
      import javax.xml.rpc.ServiceFactory;
      import java.net.URL;
      import javax.xml.namespace.QName;
      
      
      
      public class WSManager
      {
       public WSManager()
       {
       }
      
       // define a static category variable so that it references the
       // category instance of the same name as this class.
       //static final Category category = Category.getInstance(WSManager.class.getName());
      
       static {
      
       // Setup the global JAXM message factory
       System.setProperty("javax.xml.soap.MessageFactory",
       "org.jboss.ws.core.soap.MessageFactoryImpl");
      
       }
      
       public String WSManagerAddContrat() throws Exception {
       //Method level variables
       String nameContrat;
       String retour ="";
      
       try
       {
       javax.xml.rpc.ServiceFactory factory = javax.xml.rpc.ServiceFactory.newInstance();
       QName serviceName = new QName("http://contrat.com.ws", "gestionContrat");
       QName portName = new QName("http://contrat.com.ws", "ConduiteContrat");
       URL wsdlLocation = new URL("http://localhost:8080/ConduiteContrat/ConduiteContrat?WSDL");
      
       javax.xml.rpc.Service service = factory.createService(wsdlLocation, serviceName);
       javax.xml.rpc.Call call = service.createCall(serviceName, portName);
      
       retour = (String) call.invoke(new Object [] { "coucou" });
       }
       catch(javax.xml.rpc.ServiceException se) {
       se.printStackTrace();
       }
       catch(Exception e) {
       //Print the exception in the console
       e.printStackTrace();
       throw e;
       }
       return retour;
       }
      }
      


      This is my error
      10:52:37,359 INFO [TilesRequestProcessor] Tiles definition factory found for request processor ''.
      10:52:37,562 ERROR [STDERR] java.lang.IllegalArgumentException: Cannot obtain wsdl service: {http://contrat.com.ws}gestionContrat
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaDataInternal(JAXRPCClientMetaDataBuilder.java:171)
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:133)
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCClientMetaDataBuilder.buildMetaData(JAXRPCClientMetaDataBuilder.java:85)
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.ServiceImpl.<init>(ServiceImpl.java:109)
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:155)
      10:52:37,562 ERROR [STDERR] at org.jboss.ws.core.jaxrpc.client.ServiceFactoryImpl.createService(ServiceFactoryImpl.java:126)
      10:52:37,562 ERROR [STDERR] at contratwsmanager.WSManager.WSManagerAddContrat(WSManager.java:44)
      10:52:37,562 ERROR [STDERR] at contrat.ContratFormAction.execute(ContratFormAction.java:35)
      10:52:37,562 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      10:52:37,562 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      10:52:37,562 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      10:52:37,562 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      10:52:37,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      10:52:37,562 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      10:52:37,562 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      10:52:37,562 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      10:52:37,562 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      10:52:37,562 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      10:52:37,562 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      10:52:37,562 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      10:52:37,562 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      10:52:37,562 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      10:52:37,562 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
      


      My WSDL
      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:http="http://schemas.xmlsoap.org/
      wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://contrat.com.ws" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="gestionContrat" targetNamespace="http://contrat.com.ws" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:p="http://schemas.xmlsoap.org/wsdl/http/">
       <wsdl:types>
       <xsd:schema targetNamespace="http://contrat.com.ws" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:element name="toContrat">
       <xsd:complexType>
       <xsd:sequence>
       <xsd:element name="name" type="xsd:string"/>
       </xsd:sequence>
       </xsd:complexType>
       </xsd:element>
       <xsd:element name="toContratResponse">
       <xsd:complexType>
       <xsd:sequence>
       <xsd:element name="out" type="xsd:string"/>
       </xsd:sequence>
       </xsd:complexType>
       </xsd:element>
       </xsd:schema>
       </wsdl:types>
       <wsdl:message name="toContratRequest">
       <wsdl:part element="tns:toContrat" name="parameters"/>
       </wsdl:message>
       <wsdl:message name="toContratResponse">
       <wsdl:part element="tns:toContratResponse" name="parameters"/>
       </wsdl:message>
       <wsdl:portType name="ConduiteContrat">
       <wsdl:operation name="toContrat">
       <wsdl:input message="tns:toContratRequest"/>
       <wsdl:output message="tns:toContratResponse"/>
       </wsdl:operation>
       </wsdl:portType>
       <wsdl:binding name="ConduiteContratSOAP" type="tns:ConduiteContrat">
      
       <soap:binding style="document"
       transport="http://schemas.xmlsoap.org/soap/http" />
       <wsdl:operation name="toContrat">
      
       <soap:operation soapAction="http://contrat.com.ws/toContrat" />
       <wsdl:input>
      
       <soap:body use="literal" />
       </wsdl:input>
       <wsdl:output>
      
      
      
      
       <soap:body use="literal" />
       </wsdl:output>
       </wsdl:operation>
       </wsdl:binding>
       <wsdl:service name="ConduiteContratService">
       <wsdl:port binding="tns:ConduiteContratSOAP" name="gestionContratSOAP">
      
       <soap:address location="http://localhost:8080/ConduiteContrat/ConduiteContrat"/>
       </wsdl:port>
       </wsdl:service>
      </wsdl:definitions>