Trigger SOAP after Form submit
I am working with an ecommerce site that is written in Java (jsp) (2 pages in question).
We currently have a page with a 开发者_StackOverflow社区form that submits the order. Once it is sent, our server sends out an invoice email to the customer. We started using email vision a couple months ago, and my boss wanted me to use their mailing server API. Basically he is wanting (in real time), for the complete order button to be clicked and then using SOAP, send the data to emailvision who will send out the invoice for us.
I have never used an api before (or soap for that matter), and am very confused on how I am supposed to use the trigger in conjunction with the .jsp page.
You have 2 general approaches, and in both cases you need to consume a SOAP service. Consuming SOAP services is an orthogonal concern to the fact that it happens to be in a web-sever. So that is one specific question you can ask: How to consume a SOAP service in Java.
As far as web-tier and jsp in particular, you can either execute the call to consume the SOAP service in the page, or, you could allow for that action to occur somewhere in the request processing chain, by a post-action filter.
If you only need to make this call in one place then it is perfectly fine to just include it in your JSP code.
Next step up (in abstraction and reuse), you can make a custom JSP tag e.g.
<SEND-MAIL uri="your soap server uri" address="foo@bar.com" template="mail-template.txt"/>
Alternatively, you can use a Filter in the request process to send the message given certain conditions in the request context (e.g. stick a flag in the context to 'send-mail' or not.)
emailvision should have an API written in SOAP. You will need to look at the API to decide which SOAP method(s) you need to call.
In your JSP page(or backing java object) you will
- Connect to the emailvision SOAP service
- Define the methods you wish to call on that soap service
- If the method requires parameters (such as how much to put for taxes, etc), you will need to pass in the values
- Invoke the SOAP method to get back your response.
Here's a quick way to do it
精彩评论