0

I developed a web service with CXF and It work fine. I have a service with two input parameters and both of them should be mandatory. but when I call my service just the first parameter is mandatory. please let me know what should I do?

my 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);

}

and my AuthenticationResponseParam class

@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 + '\'' +
                '}';
    }
}

and my 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>

thank you

Hey guys I added a new service in my web service

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

and none of both parameters are mandatory what should I do?please help me

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
farhad
  • 373
  • 2
  • 14
  • 28
  • This has been discussed before (http://stackoverflow.com/questions/2210346/how-can-i-make-a-webmethod-parameter-required) so maybe that will help? (I'm not sure if this is a duplicate though; that depends on which versions you're using of a number of specifications…) – Donal Fellows Sep 18 '12 at 08:23
  • thank you Donal,but it doesn't help.I used @webParam in my AuthenticationRequestParam class – farhad Sep 18 '12 at 09:02

2 Answers2

0

I found what my problem. I use org.apache.cxf.aegis.databinding.AegisDatabinding az data binder and it just recognize primitive type az mandatory.when I commend that my input param become mandatory. what kind of data binder should I use?

farhad
  • 373
  • 2
  • 14
  • 28
0

If you want to use AegisDatabinding class as data binder,set this property it bean definition.

<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>
farhad
  • 373
  • 2
  • 14
  • 28