带有两个参数的Jax WS Web服务操作在调用时给出错误

时间:2013-05-31 03:11:00

标签: java web-services jax-ws

我有一个jax-ws webservice类,其操作有两个web参数。 我正在尝试向它发送一个请求但它抛出了未收到预期的JAXB元素的异常,我正在使用SOAP UI发送请求。

网络服务类

    @MTOM
    @WebService(endpointInterface = "com.carecentrix.service.ClaimService")
    public class ClaimServiceImpl implements ClaimService {

        @Resource
        public WebServiceContext context;

        private static Map<String, Object> dataMap = new HashMap<String, Object>();

        public String saveClaim(CCXClaim claim, CCXAttachment ccxAttachment) {
            String claimId = String.valueOf(dataMap.size()+1);
            if (!dataMap.containsKey(claimId)) {
                claim.getClaim().getHeaderInfo().get(0).getClaims().setClaimId(Long.valueOf(claimId));
                dataMap.put(claimId, claim);
            }
            System.out.println("claim object AppTransID" + dataMap);

            return claimId;
        }
    }

SOAP UI请求

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.carecentrix.com/" xmlns:cla="http://www.carecentrix.com/claim" xmlns:cla1="http://www.carecentrix.com/claimattachment">
       <soapenv:Header/>
       <soapenv:Body>
          <ser:saveClaim>
             <!--Optional:-->

             <cla:CCXClaim schemaVersion="1.0">
                <cla:Claim>
                   <cla:AppTransID>12233</cla:AppTransID>
                   <cla:ClaimType>I</cla:ClaimType>

                   <cla:CreatedDate>2013-05-07</cla:CreatedDate>
                   <cla:CreatedBy>rrchapp</cla:CreatedBy>
                   <cla:CreatedByProcess>rrchapp</cla:CreatedByProcess>

                   <cla:HeaderInfo>
                      <cla:Claims>

                         <cla:ClaimHeaderId>1234444</cla:ClaimHeaderId>
                         <!--Optional:-->
                         <cla:ClaimSubmitionId>1</cla:ClaimSubmitionId>
                         <cla:CreatedBy>rrchapp</cla:CreatedBy>
                         <cla:CreatedDate>2013-05-27</cla:CreatedDate>
                         <!--Optional:-->
                         <cla:CreatedProcess>biztalk</cla:CreatedProcess>
                         <!--Optional:-->
                         <cla:SubmissionVersion>1</cla:SubmissionVersion>
                         <cla:UpdatedProcess>rrchapp</cla:UpdatedProcess>
                         <cla:UpdatedBy>rrchapp</cla:UpdatedBy>
                         <cla:UpdatedDate>2013-05-27</cla:UpdatedDate>
                         <cla:ClaimId>12344444555</cla:ClaimId>
                      </cla:Claims>

                   </cla:HeaderInfo>
                   <!--Optional:-->
                   <cla:TransactionId>233</cla:TransactionId>
                   <cla:TSCreateDate>2013-05-27</cla:TSCreateDate>
                   <!--Optional:-->
                   <cla:TSPurposeCode>899</cla:TSPurposeCode>
                   <cla:UpdatedDate>2013-05-27</cla:UpdatedDate>
                   <cla:UpdatedBy>rrchapp</cla:UpdatedBy>
                   <cla:UpdatedProcess>rrchapp</cla:UpdatedProcess>

                </cla:Claim>

               <cla:DocIdentifier>
                   <cla:SourceSystem>ABCD</cla:SourceSystem>
                   <cla:SourceApplication>ABCC</cla:SourceApplication>
                   <cla:DocCreateDate>2013-05-27</cla:DocCreateDate> 
                </cla:DocIdentifier>
             </cla:CCXClaim>


             <cla1:CCXAttachment>
                <cla1:ClaimAttachment>
                   <cla1:AttachmentContent>cid:821808624369</cla1:AttachmentContent>
                </cla1:ClaimAttachment>
             </cla1:CCXAttachment>

          </ser:saveClaim>
       </soapenv:Body>
    </soapenv:Envelope>

错误

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
       <soap:Body>
          <soap:Fault>
             <faultcode>soap:Client</faultcode>
             <faultstring>Unmarshalling Error: unexpected element (uri:"http://www.carecentrix.com/claim", local:"CCXClaim"). Expected elements are &lt;{}CCXClaim>,&lt;{}CCXAttachment></faultstring>
          </soap:Fault>
       </soap:Body>
    </soap:Envelope>

上面是webservice方法,类。请求。我有两个参数,但不知何故 该服务正在甩掉故障例外 请帮助解决这个问题的原因,使用正确的命名空间发送请求。

1 个答案:

答案 0 :(得分:0)

错误消息表明预期没有名称空间的<CCXClaim>元素。但是,在您的请求中,<cla:CCXClaim>显然通过http://www.carecentrix.com/claim前缀与名称空间URI cla相关联。

由于您没有发布WSDL(和XSD,如果有的话),很难弄明白。请尝试删除请求中的clacla1前缀。