我用 CXF 开发了一个 Web 服务,它运行良好。我有一个带有两个输入参数的服务,它们都应该是强制性的。但是当我调用我的服务时,只有第一个参数是强制性的。请让我知道我该怎么办?
我的SEI
@WebService(
endpointInterface = "com.myCompany.product.webService",
targetNamespace = "http://product.myCompany.com",
portName = "product",
serviceName = "ProductService")
@DataBinding(org.apache.cxf.aegis.databinding.AegisDatabinding.class)
public interface ProductService {
@WebMethod(operationName = "authentication")
@WebResult(name = "authenticationResponseParam")
public AuthenticationResponseParam authentication(@WebParam(name = "user", header = true) String user,
@WebParam(name = "authenticationRequestParam") AuthenticationRequestParam authenticationRequestParam);
}
和我的 AuthenticationResponseParam 类
@XmlAccessorType(XmlAccessType.FIELD
)
@XmlType(name = "authenticationRequestParam", propOrder = {
"account", "password"
})
public class AuthenticationRequestParam implements Serializable {
@XmlElement(name = "account", required = true)
private BigDecimal account;
@XmlElement(name = "password", required = true)
private String password;
public BigDecimal getAccount() {
return account;
}
public void setAccount(BigDecimal account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "AuthenticationRequestParam{" +
"account=" + account +
", password='" + password + '\'' +
'}';
}
}
和我的 CXF servlet xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<!--Data binding-->
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype"/>
<bean id="jaxws-and-aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
<property name="dataBinding" ref="aegisBean"/>
</bean>
<jaxws:endpoint id="telBank" implementor="#myService" address="/telBank">
<jaxws:binding>
<soap:soapBinding mtomEnabled="false" version="1.2"/>
</jaxws:binding>
</jaxws:endpoint>
<bean id="myService" class="com.myCompany.product.webService.impl.ProductServiceImpl"/>
</beans>
谢谢你
嘿伙计们,我在我的网络服务中添加了一项新服务
public BigDecimal sample(@WebParam(name = "sam1") BigDecimal a1,@WebParam(name = "sam2") BigDecimal a2);
并且这两个参数都不是强制性的我该怎么办?请帮助我