所以我试图用JAXB和spring-ws webservicetemplate编写我的肥皂响应,而且它不是在这里工作是我的相关代码
SoapUI响应
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getAccountProductsResponse xmlns="http://CellucomPosa/">
<getAccountProductsResult>
<CellucomPOSA xmlns="">
<Product>
<ProductID>280</ProductID>
<ProductName>AT&T $15</ProductName>
<Discount>18</Discount>
<Price>15.00</Price>
<ProdType>PINRTR</ProdType>
</Product>
<Product>
<ProductID>281</ProductID>
<ProductName>AT&T $25</ProductName>
<Discount>18</Discount>
<Price>25.00</Price>
<ProdType>PINRTR</ProdType>
</Product>
</CellucomPOSA>
</getAccountProductsResult>
</getAccountProductsResponse>
</soap:Body>
</soap:Envelope>
这是春天的背景
<oxm:jaxb2-marshaller id="marshaller" contextPath="cellucomposa"/>
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="soapVersion">
<util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/>
</property>
</bean>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory"/>
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="defaultUri" value="http://Service.asmx"/>
</bean>
这是cellucomposa中的对象
package cellucomposa;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="getAccountProductsResponse")
public class GetAccountProductsResponse
{
@XmlElement(name="getAccountProductsResult", type=GetAccountProductsResult.class)
private GetAccountProductsResult getAccountProductsResult;
public GetAccountProductsResult getGetAccountProductsResult ()
{
return getAccountProductsResult;
}
public void setGetAccountProductsResult (GetAccountProductsResult getAccountProductsResult)
{
this.getAccountProductsResult = getAccountProductsResult;
}
}
package cellucomposa;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="getAccountProductsResult")
public class GetAccountProductsResult
{
@XmlElement(name="CellucomPOSA", type=CellucomPOSA.class)
private CellucomPOSA CellucomPOSA;
public CellucomPOSA getCellucomPOSA ()
{
return CellucomPOSA;
}
public void setCellucomPOSA (CellucomPOSA CellucomPOSA)
{
this.CellucomPOSA = CellucomPOSA;
}
}
package cellucomposa;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlRootElement(name="CellucomPOSA")
@XmlAccessorType(XmlAccessType.FIELD)
public class CellucomPOSA {
@XmlElement(name="Product", type=Product.class)
private Product[] Product;
public Product[] getProduct ()
{
return Product;
}
public void setProduct (Product[] Product)
{
this.Product = Product;
}
}
package cellucomposa;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="Product")
@XmlAccessorType(XmlAccessType.FIELD)
public class Product {
@XmlElement(name="Price")
private String Price;
@XmlElement(name="ProductID")
private String ProductID;
@XmlElement(name="ProductName")
private String ProductName;
@XmlElement(name="Discount")
private String Discount;
@XmlElement(name="ProdType")
private String ProdType;
public String getPrice ()
{
return Price;
}
public void setPrice (String Price)
{
this.Price = Price;
}
public String getProductID ()
{
return ProductID;
}
public void setProductID (String ProductID)
{
this.ProductID = ProductID;
}
public String getProductName ()
{
return ProductName;
}
public void setProductName (String ProductName)
{
this.ProductName = ProductName;
}
public String getDiscount ()
{
return Discount;
}
public void setDiscount (String Discount)
{
this.Discount = Discount;
}
public String getProdType ()
{
return ProdType;
}
public void setProdType (String ProdType)
{
this.ProdType = ProdType;
}
}
以下是发出请求的服务实现
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.oxm.XmlMappingException;
import org.springframework.stereotype.Service;
import org.springframework.ws.client.core.WebServiceTemplate;
import cellucomposa.GetAccountProductsResponse;
@Service
public class TcetraServiceImpl implements TcetraService {
private static final Logger logger = Logger.getLogger(TcetraServiceImpl.class);
@Autowired
private WebServiceTemplate webServiceTemplate;
@Override
public GetAccountProductsResponse getProducts(GetAccountProducts request) {
GetAccountProductsResponse response = (GetAccountProductsResponse) webServiceTemplate.marshalSendAndReceive(request);
return response;
}
}
请求没有问题,响应映射到pojo没有任何问题没有任何错误,但CellucomPOSA元素始终为null,即使soapui响应显示其他情况并且请求对象与soapui完全相同以及&#39 ; s进入webservicetemlate。知道这里可能出了什么问题吗?