2014-09-12 4 views
0

Java 1.7 Spring 3.1.1 с Spring-WS 2.1.1 Joda Hibernate 3.6 MySQL 5.0.57 Maven 3 Tomcat 7 Eclipse, 3.7использовании веб-сервиса - JaxWsPortProxyFactoryBean или контроллер не настроен правильный

Итак, веб-сервис SOAP запущен.

И мое автономное приложение Java может получить к нему доступ.

Теперь я пытаюсь создать веб-клиент Spring MVC для доступа к нему. Таким образом, по моему способу мышления я могу просто заменить стандартный сервисный уровень webapp на конечную точку веб-службы.

Образец после этого http://ankeetmaini.wordpress.com/2013/03/04/jax-ws-client-consuming-the-jax-ws-webservice после включения его соглашения об именах более каноническим я завелся с

FormsEndpointImplService

@WebServiceClient(name = "FormsEndpointImplService", 
        wsdlLocation = "http://localhost:8080/dept_forms_webservice/formsService?wsdl", 
        targetNamespace = "http://endpoint.web.forms.azdeq.gov/") 
public class FormsEndpointImplService extends Service 
{ 
    public final static URL WSDL_LOCATION; 

    public final static QName SERVICE = new QName("http://endpoint.web.forms.azdeq.gov/", "FormsEndpointImplService"); 
    public final static QName FormsEndpointImplPort = new QName("http://endpoint.web.forms.azdeq.gov/", "FormsEndpointImplPort"); 
    static { 
     URL url = null; 
     try { 
      url = new URL("http://localhost:8080/dept_forms_webservice/formsService?wsdl"); 
     } catch (MalformedURLException e) { 
      java.util.logging.Logger.getLogger(FormsEndpointImplService.class.getName()) 
       .log(java.util.logging.Level.INFO, 
        "Can not initialize the default wsdl from {0}", "http://localhost:8080/dept_forms_webservice/formsService?wsdl"); 
     } 
     WSDL_LOCATION = url; 
    } 

    public FormsEndpointImplService(URL wsdlLocation) { 
     super(wsdlLocation, SERVICE); 
    } 

    public FormsEndpointImplService(URL wsdlLocation, QName serviceName) { 
     super(wsdlLocation, serviceName); 
    } 

    public FormsEndpointImplService() { 
     super(WSDL_LOCATION, SERVICE); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public FormsEndpointImplService(WebServiceFeature ... features) { 
     super(WSDL_LOCATION, SERVICE, features); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public FormsEndpointImplService(URL wsdlLocation, WebServiceFeature ... features) { 
     super(wsdlLocation, SERVICE, features); 
    } 

    //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 
    //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 
    //compliant code instead. 
    public FormsEndpointImplService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { 
     super(wsdlLocation, serviceName, features); 
    } 

    /** 
    * 
    * @return 
    *  returns FormsEndpoint 
    */ 
    @WebEndpoint(name = "FormsEndpointImplPort") 
    public FormsEndpoint getFormsEndpointImplPort() { 
     return super.getPort(FormsEndpointImplPort, FormsEndpoint.class); 
    } 

    /** 
    * 
    * @param features 
    *  A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. 
    * @return 
    *  returns FormsEndpoint 
    */ 
    @WebEndpoint(name = "FormsEndpointImplPort") 
    public FormsEndpoint getFormsEndpointImplPort(WebServiceFeature... features) { 
     return super.getPort(FormsEndpointImplPort, FormsEndpoint.class, features); 
    } 
} 

FormsEndpoint (ГЙ)

@WebService(targetNamespace = "http://endpoint.web.forms.azdeq.gov/", name = "FormsEndpoint") 
@XmlSeeAlso({ObjectFactory.class}) 
public interface FormsEndpoint 
{ 
    @RequestWrapper(localName = "insertCompletedForm", targetNamespace = "http://endpoint.web.forms.azdeq.gov/", className = "gov.azdeq.forms.web.endpoint.InsertCompletedForm") 
    @WebMethod 
    @ResponseWrapper(localName = "insertCompletedFormResponse", targetNamespace = "http://endpoint.web.forms.azdeq.gov/", className = "gov.azdeq.forms.web.endpoint.InsertCompletedFormResponse") 
    public void insertCompletedForm(
     @WebParam(name = "arg0", targetNamespace = "") 
     gov.azdeq.forms.web.endpoint.CompletedForm arg0 
    ); 
....  

}

и мой сервлет-context.xml

... 
<bean id="formsWebServiceProxy" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean"> 
    <property name="wsdlDocumentUrl" value="http://localhost:8080/dept_forms_webservice/formsService?wsdl"/> 
    <property name="serviceInterface" value="gov.azdeq.forms.web.endpoint.FormsEndpoint"/> 
    <property name="serviceName"  value="FormsEndpointImplService"/> 
    <property name="portName"   value="FormsEndpointImplPort"/> 
    <property name="namespaceUri"  value="http://endpoint.web.forms.azdeq.gov/"/> 
    <!-- <property name="endpointAddress" value="http://endpoint.web.forms.azdeq.gov/" /> --> 
</bean> 

<bean id="baseController"    class="gov.azdeq.forms.web.controller.BaseController"> 
    <property name="service"   ref="formsWebServiceProxy" /> 
</bean> 

... 

и базовый контроллер

@RequestMapping 
@Controller 
public class BaseController 
{ 
    private static final Logger logger = Logger.getLogger(BaseController.class); 

    @Resource 
    FormsEndpoint service; // should come in from bean 
    ... 
} 

Так что это все компилируется и развертывается Tomcat просто отлично. Но когда я нажимаю на dept_forms_webclient в локальном хосте: 8080/менеджер он бросает это:

org.springframework.beans.NotWritablePropertyException: Invalid property 'service' of bean class [gov.azdeq.forms.web.controller.BaseController]: Bean property 'service' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? 

Похож прокси-боб впрыскивается хорошо, кажется, что я не должен установить его в FormsEndpoint независимо от того, каких различного Tuts сказать.

Итак, больше путаницы в конфигурации, может ли кто-нибудь определить, что здесь не так?

ТИА,

Еще обучения STEV

+0

Remote XML-декларация 'baseController' вы используете аннотации для инъекций не ручной настройки. Или добавьте сеттер для свойства сервиса (это то, что на самом деле говорит об исключении). –

ответ

0

Я получил все это работает, потеряв зависимость инъекции в файле контекста и используя @Autowired в контроллере так:

<!-- controllers -->  
<bean id="baseController"     class="gov.azdeq.forms.web.controller.BaseController" /> 

и

@RequestMapping 
@Controller("baseController") 
public class BaseController 
{ 
    @Autowired 
    @Resource(name="formsWebServicePortProxy") 
    FormsEndpoint formsWebServicePortProxy; 

Не знаете, почему использование @Автоматические работы, но ручные свойство инъекция нет. Да.

Спасибо всем, кто ответил, это дало мне немного проницательности.

ДЕЛО ЗАКРЫТО

Еще обучения Стив