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
因此 SOAP Web 服务已启动并正在运行。
我的独立 Java 应用程序可以访问它。
现在我正在尝试构建一个 Spring MVC Web 客户端来访问它。因此,按照我的想法,我可以将标准 webapp 的服务层替换为 web 服务端点。
在将他的命名约定切换为更规范之后,在此 http://ankeetmaini.wordpress.com/2013/03/04/jax-ws-client-sumption-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 (SEI)
@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
);
....
}
和我的 servlet-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就好了。但是当我点击 localhost:8080/manager 中的 dept_forms_webclient 时,它会抛出这个:
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?
似乎代理 bean 被注入了,似乎我不应该将它设置为 FormsEndpoint,不管各种 tuts 说什么。
所以,更多的配置混乱,任何人都可以发现这里有什么问题吗?
TIA,
仍在学习的史蒂夫