0

CXF を使用して Web サービスを開発しましたが、正常に動作します。2 つの入力パラメーターを持つサービスがあり、両方とも必須である必要があります。しかし、サービスを呼び出すときは、最初のパラメーターだけが必須です。私は何をすべきか教えてください。

私の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サーブレット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>

ありがとうございました

こんにちは、Web サービスに新しいサービスを追加しました

public BigDecimal sample(@WebParam(name = "sam1") BigDecimal a1,@WebParam(name = "sam2") BigDecimal a2);

どちらのパラメータも必須ではありません。どうすればよいですか?助けてください

4

2 に答える 2

0

AegisDatabindingクラスをデータバインダーとして使用する場合は、このプロパティをBean定義に設定します。

<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
    <property name="configuration">
        <bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
            <property name="defaultMinOccurs" value="1"/>
            <property name="defaultNillable" value="false"/>
        </bean>
    </property>
</bean>
于 2012-09-23T04:56:33.220 に答える
0

私は自分の問題を見つけました。私は org.apache.cxf.aegis.databinding.AegisDatabinding az データ バインダーを使用していますが、入力パラメーターが必須になることを推奨すると、プリミティブ型 az 必須を認識するだけです。どのようなデータバインダーを使用すればよいですか?

于 2012-09-19T05:22:23.663 に答える