java - Spring autowired issue with webservice -


i creating webservice , have use service in it. there autowired not working,i tried lot of things it.

my directory structure is:

package com.mycaptionlabs.quickbooks.ws;  import java.util.arraylist;  import javax.jws.webservice;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.web.context.support.springbeanautowiringsupport;  import com.mycaptionlabs.repository.userrepository; import com.mycaptionlabs.service.userservice;  /*  * http://developer.intuit.com/qbsdk-current/doc/pdf/qbwc_proguide.pdf  */  @webservice(endpointinterface = "com.mycaptionlabs.quickbooks.ws.qbwebconnectorsvcsoap") public class itemqueryrqsoapimpl extends springbeanautowiringsupport implements qbwebconnectorsvcsoap {      userrepository userrepository;      @autowired userservice userservice;      @override     public arrayofstring authenticate(string strusername, string strpassword) {         system.out.println(userservice);          arrayofstring arr = new arrayofstring();         arr.string = new arraylist<string>();         arr.string.add("the first element token web connectorÕs session");         arr.string.add(""); // use open company, specify                             // empty string         return arr;     }      @override     public string closeconnection(string ticket) {         // todo auto-generated method stub         return null;     }      @override     public string connectionerror(string ticket, string hresult, string message) {         // todo auto-generated method stub         return null;     }      @override     public string getlasterror(string ticket) {         // todo auto-generated method stub         return null;     }      /**      * @return positive integer less 100 represents percentage of      *         work completed. value of 1 means 1 percent complete, value      *         of 100 means 100 percent complete--there no more work.      *         negative value means error has occurred , web connector      *         responds getlasterror call. negative value      *         used custom error code.      */     @override     public int receiveresponsexml(string ticket, string response, string hresult, string message) {         // todo auto-generated method stub         return 100;     }      @override     public string sendrequestxml(string ticket, string strhcpresponse, string strcompanyfilename, string qbxmlcountry,             int qbxmlmajorvers, int qbxmlminorvers) {         // example qbxml query item         // http://www.consolibyte.com/wiki/doku.php/quickbooks_qbxml_itemquery         string query = "<?xml version=\"1.0\" encoding=\"utf-8\"?><?qbxml version=\"7.0\"?><qbxml><qbxmlmsgsrq onerror=\"stoponerror\"><itemqueryrq requestid=\"sxrlbvf1zxj5fdeyma==\"><ownerid>0</ownerid></itemqueryrq></qbxmlmsgsrq></qbxml>";         return query;     }  } 

and interface is

package com.mycaptionlabs.quickbooks.ws;  import javax.jws.webmethod; import javax.jws.webparam; import javax.jws.webresult; import javax.jws.webservice; import javax.xml.bind.annotation.xmlseealso; import javax.xml.ws.requestwrapper; import javax.xml.ws.responsewrapper;   /**  * class generated jax-ws ri.  * jax-ws ri 2.1.6 in jdk 6  * generated source version: 2.1  *   */ @webservice(name = "qbwebconnectorsvcsoap", targetnamespace = "http://developer.intuit.com/") @xmlseealso({     objectfactory.class }) public interface qbwebconnectorsvcsoap {       /**      *       * @param strpassword      * @param strusername      * @return      *     returns com.cantero.quickbooks.ws.arrayofstring      */     @webmethod(action = "http://developer.intuit.com/authenticate")     @webresult(name = "authenticateresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "authenticate", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.authenticate")     @responsewrapper(localname = "authenticateresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.authenticateresponse")     public arrayofstring authenticate(         @webparam(name = "strusername", targetnamespace = "http://developer.intuit.com/")         string strusername,         @webparam(name = "strpassword", targetnamespace = "http://developer.intuit.com/")         string strpassword);      /**      *       * @param qbxmlminorvers      * @param ticket      * @param qbxmlcountry      * @param strcompanyfilename      * @param qbxmlmajorvers      * @param strhcpresponse      * @return      *     returns java.lang.string      */     @webmethod(action = "http://developer.intuit.com/sendrequestxml")     @webresult(name = "sendrequestxmlresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "sendrequestxml", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.sendrequestxml")     @responsewrapper(localname = "sendrequestxmlresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.sendrequestxmlresponse")     public string sendrequestxml(         @webparam(name = "ticket", targetnamespace = "http://developer.intuit.com/")         string ticket,         @webparam(name = "strhcpresponse", targetnamespace = "http://developer.intuit.com/")         string strhcpresponse,         @webparam(name = "strcompanyfilename", targetnamespace = "http://developer.intuit.com/")         string strcompanyfilename,         @webparam(name = "qbxmlcountry", targetnamespace = "http://developer.intuit.com/")         string qbxmlcountry,         @webparam(name = "qbxmlmajorvers", targetnamespace = "http://developer.intuit.com/")         int qbxmlmajorvers,         @webparam(name = "qbxmlminorvers", targetnamespace = "http://developer.intuit.com/")         int qbxmlminorvers);      /**      *       * @param message      * @param response      * @param ticket      * @param hresult      * @return      *     returns int      */     @webmethod(action = "http://developer.intuit.com/receiveresponsexml")     @webresult(name = "receiveresponsexmlresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "receiveresponsexml", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.receiveresponsexml")     @responsewrapper(localname = "receiveresponsexmlresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.receiveresponsexmlresponse")     public int receiveresponsexml(         @webparam(name = "ticket", targetnamespace = "http://developer.intuit.com/")         string ticket,         @webparam(name = "response", targetnamespace = "http://developer.intuit.com/")         string response,         @webparam(name = "hresult", targetnamespace = "http://developer.intuit.com/")         string hresult,         @webparam(name = "message", targetnamespace = "http://developer.intuit.com/")         string message);      /**      *       * @param message      * @param ticket      * @param hresult      * @return      *     returns java.lang.string      */     @webmethod(action = "http://developer.intuit.com/connectionerror")     @webresult(name = "connectionerrorresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "connectionerror", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.connectionerror")     @responsewrapper(localname = "connectionerrorresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.connectionerrorresponse")     public string connectionerror(         @webparam(name = "ticket", targetnamespace = "http://developer.intuit.com/")         string ticket,         @webparam(name = "hresult", targetnamespace = "http://developer.intuit.com/")         string hresult,         @webparam(name = "message", targetnamespace = "http://developer.intuit.com/")         string message);      /**      *       * @param ticket      * @return      *     returns java.lang.string      */     @webmethod(action = "http://developer.intuit.com/getlasterror")     @webresult(name = "getlasterrorresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "getlasterror", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.getlasterror")     @responsewrapper(localname = "getlasterrorresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.getlasterrorresponse")     public string getlasterror(         @webparam(name = "ticket", targetnamespace = "http://developer.intuit.com/")         string ticket);      /**      *       * @param ticket      * @return      *     returns java.lang.string      */     @webmethod(action = "http://developer.intuit.com/closeconnection")     @webresult(name = "closeconnectionresult", targetnamespace = "http://developer.intuit.com/")     @requestwrapper(localname = "closeconnection", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.closeconnection")     @responsewrapper(localname = "closeconnectionresponse", targetnamespace = "http://developer.intuit.com/", classname = "com.cantero.quickbooks.ws.closeconnectionresponse")     public string closeconnection(         @webparam(name = "ticket", targetnamespace = "http://developer.intuit.com/")         string ticket);  } 

main class is:

package com.mycaptionlabs;

import javax.xml.ws.endpoint;  import org.slf4j.logger; import org.slf4j.loggerfactory; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.boot.context.web.springbootservletinitializer; import org.springframework.context.annotation.propertysource; import org.springframework.context.annotation.propertysources; import org.springframework.scheduling.annotation.enablescheduling;  import com.mycaptionlabs.quickbooks.ws.itemqueryrqsoapimpl;  @springbootapplication @enablescheduling @propertysources({     @propertysource("classpath:datasource.properties"),     @propertysource("classpath:mail.properties") }) public class mycaptionlabsapplication extends springbootservletinitializer{       public static logger log = loggerfactory.getlogger(mycaptionlabsapplication.class);         @override         protected springapplicationbuilder configure(springapplicationbuilder application) {             return application.sources(mycaptionlabsapplication.class);         }        public static void main(string[] args) {         log.debug("running application");                 springapplication.run(mycaptionlabsapplication.class, args);         endpoint.publish("http://localhost:8080/qbwebservice",                 new itemqueryrqsoapimpl());      } } 

and user service is

@service public class userservice{  } 

i have tried link jboss 6 + spring 3.0.5 + jax-ws/cxf doesn't work me. please me missing there,is there directory structure wrong ?

thanks in advance!!

@autowired (as @value, @inject, etc.) works in spring managed beans. create instance of itemqueryrqsoapimpl manually.

  1. add @component or @service itemqueryrqsoapimpl class declaration, or create method returning instance of itemqueryrqsoapimpl , annotated @bean.

  2. get created bean using applicationcontext.getbean() , pass endpoint.publish()

you shoud this:

    public static logger log = loggerfactory.getlogger(mycaptionlabsapplication.class);      @bean     public itemqueryrqsoapimpl itemqueryrqsoapimpl() {         return new itemqueryrqsoapimpl();     }      @override     protected springapplicationbuilder configure(springapplicationbuilder application) {         return application.sources(mycaptionlabsapplication.class);     }      public static void main(string[] args) {         log.debug("running application");                 applicationcontext applicationcontext = springapplication.run(mycaptionlabsapplication.class, args);         itemqueryrqsoapimpl itemqueryrqsoapimpl = applicationcontext.getbean(itemqueryrqsoapimpl.class);          endpoint.publish("http://localhost:8080/qbwebservice",             itemqueryrqsoapimpl);  } 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -