简体   繁体   中英

Getting a soap request using java and web services

I'm working with an organization's payment API. The API automatically posts a soap request to our server when a customer makes payment, like so

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c2b="http://cps.huawei.com/cpsinterface/c2bpayment">
       <soapenv:Header/>
       <soapenv:Body>
          <c2b:C2BPaymentConfirmationRequest>
             <TransactionType>PayBill</TransactionType>
             <TransID>1234560000007031</TransID>
             <TransTime>20140227082020</TransTime>
             <TransAmount>123.00</TransAmount>
             <BusinessShortCode>12345</BusinessShortCode>
             <BillRefNumber>TX1001</BillRefNumber>
             <InvoiceNumber></InvoiceNumber>
             <OrgAccountBalance>12345.00</OrgAccountBalance>
             <ThirdPartyTransID></ThirdPartyTransID>
             <MSISDN>254722703614</MSISDN>
             <KYCInfo>
                <KYCName>[Personal Details][First Name]</KYCName>
                <KYCValue>Hoiyor</KYCValue>
             </KYCInfo>
          </c2b:C2BPaymentConfirmationRequest>
       </soapenv:Body>
    </soapenv:Envelope>

And I give a soap response.

My question is

Should I use SAAJ to create a soap client only to receive the soap request and post the details to my database then generate a soap response? Is the an example like this?

OR

Should I generate code to simply receive xml data, read the contents and generate a soap response?

I am abit confused on which is the best method. Forgive my ignorance.

Should I use SAAJ to create a soap client only to receive the soap request and post the details to my database then generate a soap response?

If you receive requests — it is a server not a client.

My advice is to use spring-ws with JAXB — it is pretty simply. If you have a chance don't use JEE stuff don't use it, because of implementation of JEE can varies between applications server. For an example old versions of WebSphere have some problems with JEE implementation.

Should I generate code to simply receive xml data, read the contents and generate a soap response?

It is a very bad idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM