Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Sending Form info with SOAP
Old 04-10-2009, 02:42 PM Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Does anybody know proper syntax for sending form information with a soap script? Is it just XML format? Here is the API info sent from their IT department:

Request:
Code:
POST /webservices2/SmartLifeQuoteWebService/SmartLife.asmx HTTP/1.1
Host: secure.sas-it.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetRatesFromCriteria xmlns="https://secure.sas-it.com/webservices2/SmartLifeQuoteWebService/">
      <AgentKey>string</AgentKey>
      <CustomerState>string</CustomerState>
      <TobaccoUser>boolean</TobaccoUser>
      <CustomerGender>string</CustomerGender>
      <FaceAmt>int</FaceAmt>
      <CustomerDOB>string</CustomerDOB>
      <CustomerEmail>string</CustomerEmail>
      <IpAddress>string</IpAddress>
      <URLReferrer>string</URLReferrer>
      <AgentRefNumber>string</AgentRefNumber>
      <ROI>string</ROI>
    </GetRatesFromCriteria>
  </soap12:Body>
</soap12:Envelope>

Response:

Code:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <GetRatesFromCriteriaResponse xmlns="https://secure.sas-it.com/webservices2/SmartLifeQuoteWebService/">
      <GetRatesFromCriteriaResult>
        <xsd:schema>schema</xsd:schema>xml</GetRatesFromCriteriaResult>
    </GetRatesFromCriteriaResponse>
  </soap12:Body>
</soap12:Envelope>
Jasonpv is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-10-2009, 05:17 PM Re: Sending Form info with SOAP
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
There's a very good post on IBM Developerworks that covers this very topic
http://www.ibm.com/developerworks/we...ary/ws-wsajax/
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 04-10-2009, 05:35 PM Re: Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Wow, that is perfect! Thank you!

So, it looks like common practice is to use javascript to create and send the SOAP envelope for you?
Jasonpv is offline
Reply With Quote
View Public Profile
 
Old 04-10-2009, 05:41 PM Re: Sending Form info with SOAP
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
I've had some rare occasions to do it but, generally, I use Java instead of javascript.

Keep in mind, due to browser security, the soap service will need to be on the same host as the page in the browser.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 04-10-2009, 05:46 PM Re: Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
That is one of my concerns with this project. Basically we are creating our own custom front-end for a quoting service that provides a generic one. So we will be hosting the html/php files on our server but the quote generating/application process is done on their server. I talked with their IT guy and he assured me that it was a secure "channel". Personally, I was thinking that we would need to purchase a security certificate to be able to send the data securely. What are your thoughts?
Jasonpv is offline
Reply With Quote
View Public Profile
 
Old 04-14-2009, 12:35 PM Re: Sending Form info with SOAP
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
The notion of a secure channel is relative. Traffic may be encrypted but, it can still depend on what things are allowed via that "secure" channel.

For a case like yours, I would generally recommend creating a little proxy that allowed REST on the browser side and let the SOAP happen between servers. The REST service could return JSON making the bowser scripting part much easier.

The light proxy code on the server would be lightweight and easy to test. It would also eliminate the cross-domain issue since the proxy would live on the same server that sends up the pages.
__________________

Please login or register to view this content. Registration is FREE

willcode4beer is offline
Reply With Quote
View Public Profile
 
Old 04-15-2009, 12:12 AM Re: Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Hmmm, I'll have to look into that a bit more. Would be my first time creating a proxy but from the sound of it shouldn't be too difficult...Thank you so much for the info, I owe ya a case of beer!
Jasonpv is offline
Reply With Quote
View Public Profile
 
Old 04-22-2009, 12:19 PM Re: Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Quote:
Originally Posted by willcode4beer View Post
I've had some rare occasions to do it but, generally, I use Java instead of javascript.

Keep in mind, due to browser security, the soap service will need to be on the same host as the page in the browser.
Do you know how I can get the form values from html into my java code (not javascript)? I am having trouble finding info on how to do this. Here is my Java class below, should this do the trick?

Code:
import java.net.*;
import java.io.*;
 
public class PostXml implements java.io.Serializable {
	protected static String _firstName, _lastName, _address, _phone, _email;
	
	public PostXml() {
	    this(null, null, null, null, null);
	  }
 
	  public PostXml(String first_name, String last_name, String address, String phone,
			  String email) {
	    _firstName = first_name;
	    _lastName = last_name;
	    _address = address;
	    _phone = phone;
	    _email = email;
	  }
 
  
	
	public static void main(String[] args) {
		
    try {
    	
      String contents = obj.value;     // Retrieve value
 
      
      String xmldata = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
      					"<soap12:Envelope" +
      					"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
      					"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
      					"xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
  "<soap12:Body>" +
    "<GetRatesFromCriteria xmlns=\"https://host..blah.com/\">" +
      "<AgentKey>string</AgentKey>" +
      "<CustomerState>" + _state + "</CustomerState>" +
      "<TobaccoUser>" + _tobacco + "</TobaccoUser>" +
      "<CustomerGender>" + _gender + "</CustomerGender>" +
      "<FaceAmt>" + coverageAmt + "</FaceAmt>" +
      "<CustomerDOB>string</CustomerDOB>" +
      "<CustomerEmail>" + _email + "</CustomerEmail>" +
      "<IpAddress>string</IpAddress>" +
      "<URLReferrer>string</URLReferrer>" +
      "<AgentRefNumber>string</AgentRefNumber>" +
      "<ROI>string</ROI>" +
    "</GetRatesFromCriteria>" +
  "</soap12:Body>" +
"</soap12:Envelope>";
			
      //Create socket
      String hostname = "host.host.com";
      int port = 80;
      InetAddress  addr = InetAddress.getByName(hostname);
      Socket sock = new Socket(addr, port);
			
      //Send header
      String path = "xxx.blah.com";
      BufferedWriter  wr = new BufferedWriter(new OutputStreamWriter(sock.getOutputStream(),"UTF-8"));
      // You can use "UTF8" for compatibility with the Microsoft virtual machine.
      wr.write("POST " + path + " HTTP/1.1\r\n");
      wr.write("Host: secure.sas-it.com\r\n");
      wr.write("Content-Type: application/soap+xml; charset=utf-8\"\r\n");
      wr.write("Content-Length: " + xmldata.length() + "\r\n");
      wr.write("\r\n");
			
      //Send data
      wr.write(xmldata);
      wr.flush();
			
      // Response
      BufferedReader rd = new BufferedReader(new InputStreamReader(sock.getInputStream()));
      String line;
      while((line = rd.readLine()) != null)
	System.out.println(line);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
Jasonpv is offline
Reply With Quote
View Public Profile
 
Old 04-24-2009, 02:52 PM Re: Sending Form info with SOAP
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Any ideas? Also, can I just place a java class file on the server and call it to run. or do I need to have JRE installed?

Last edited by Jasonpv; 04-24-2009 at 03:35 PM..
Jasonpv is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Sending Form info with SOAP
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43023 seconds with 12 queries