Guide
  • Introduction
  • Intro
    • Introduction
  • Beginner
    • How to send a param to another page
    • How to fill a select/combobox, radiolist, checkboxlist
    • How to order a list by a columm (java)
    • How to change the first page(home) of an application
  • Intermediate
    • How to make a filter/search with QueryInterface
    • How to hide a table context button?
    • How to show a file in a table
    • How to consume a JSON... GET and POST
    • How to make a SoapRequest
    • How to fill SeparatorList or FormList
    • How to map an entity to table using hibernate??
  • Advanced
    • OUT OF SERVICE - How to use a switch in a table - UI designer
    • How to implement a process BPMN in IGRP Studio
Powered by GitBook
On this page
  1. Intermediate

How to make a SoapRequest

PreviousHow to consume a JSON... GET and POSTNextHow to fill SeparatorList or FormList

Last updated 6 years ago

The script below does a SOAP requirment (wsdl = "") ... from an IP address that is entered by the user illustrated in the figure 1, and then returns the regional information of this IP and fills in the table also shown in the figure 1.

Page is called Soaptest
public Response actionIndex() throws IOException, IllegalArgumentException, IllegalAccessException {
		Soaptest model = new Soaptest();
		model.load();
		SoaptestView view = new SoaptestView();
		/*----#gen-example
		  EXAMPLES COPY/PASTE:
		  INFO: Core.query(null,... change 'null' to your db connection name, added in Application Builder.
		model.loadTable_1(Core.query(null,"SELECT 'Accusantium perspiciatis amet' as cidade,'Sit natus sit aperiam sit' as country,'Lorem unde ut rem consectetur' as country_code,'Omnis ut voluptatem unde rem' as latitude,'Rem totam accusantium deserunt' as longitude,'Magna ipsum doloremque totam u' as provincia "));
		  ----#gen-example */
		/*----#start-code(index)----*/

		String wsdlUrl = "http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl";

// An Map of Soap HTTP Headers 
		Map<String, String> headers = new HashMap<String, String>();
		headers.put("soapAction", "http://ws.cdyne.com/ResolveIP");

// An Map of Soap Envelope namespace 
		Map<String, String> namespaces = new HashMap<String, String>();
		namespaces.put("SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope");
		namespaces.put("ws", "http://ws.cdyne.com/");

// <ws:ResolveIP>
//    <ws:ipAddress>?</ws:ipAddress>
//    <ws:licenseKey>?</ws:licenseKey>
//</ws:ResolveIP>

		Map<String, Object> bodyContent = new HashMap<String, Object>();
		Map<String, Object> subContent = new HashMap<String, Object>();
		if (Core.isNotNull(model.getIp_address())) {

			subContent.put("ws:ipAddress", model.getIp_address());
			subContent.put("ws:licenseKey", "");
			bodyContent.put("ws:ResolveIP", subContent);

			nosi.core.webapp.webservices.soap.SoapClient sc = Core.soapClient(wsdlUrl, namespaces, headers,
					bodyContent);

			if (sc != null && sc.hasErrors()) { // Verifica se ocorreu algum erro ...
				Core.setMessageError(Arrays.toString(sc.getErrors().toArray()));
			} else {// Preencher os dados na tabela

// retorna soap body como um java.util.Map 
				Map<String, Object> map = sc.getResponseBody("soap");
				if (map != null) {
					List<Soaptest.Table_1> table1 = new ArrayList<>();
					map = (Map<String, Object>) map.get("ResolveIPResponse");
					if (map != null)
						map.forEach((k, v) -> {
							Map<String, String> l = (Map<String, String>) v;

							Soaptest.Table_1 row = new Soaptest.Table_1();
							row.setCidade(l.get("City"));
							row.setCountry(l.get("Country"));
							row.setCountry_code(l.get("CountryCode"));
							row.setLatitude(l.get("Latitude"));
							row.setLongitude(l.get("Longitude"));
							row.setProvincia(l.get("StateProvince"));

							table1.add(row);
						});
					model.setTable_1(table1);
				}

			}
		}

		/*----#end-code----*/
		view.setModel(model);
		return this.renderView(view);
	}
http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl
Figure 1