0% found this document useful (0 votes)
37 views6 pages

Web Security Lab Ex2

The document describes an experiment to implement a business UDDI registry entry. It involves creating a new web service called "2nd" and a Java class file called "HelloWorld.java" with code to define a UDDISoapClient. The code declares XML namespaces, creates a SOAP envelope containing the body elements from an XML data file, and sends the SOAP message to a URL, receiving and printing the response.

Uploaded by

Rithik Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views6 pages

Web Security Lab Ex2

The document describes an experiment to implement a business UDDI registry entry. It involves creating a new web service called "2nd" and a Java class file called "HelloWorld.java" with code to define a UDDISoapClient. The code declares XML namespaces, creates a SOAP envelope containing the body elements from an XML data file, and sends the SOAP message to a URL, receiving and printing the response.

Uploaded by

Rithik Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

EXPERIMENT: 2

Student Name: Hrithik UID: 19BCS1856


Branch: CSE Section/Group: 19BCS-23(A)
Semester: 7th Date of Performance: 20/08/20
Subject Name : Web Security lab Subject Code: CSB-422

Aim: Write a program to implement business UDDI Registry entry.


Solution:
UDDI stands for Universal Description, Discovery, and Integration. The UDDI project is an industry
initiative aims to enable businesses to quickly, easily, and dynamically find and carry out transactions
with one another.

 Created a new Web Service named 2nd

 Right click on Source Packages >> New >> Java Class

This study source was downloaded by 100000832295719 from CourseHero.com on 08-29-2022 08:52:48 GMT -05:00

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/
 Create new web-service:

 HelloWorld.java file would be created with code as


follows: import java.io.*;
importjava.util.*;
public class UDDISoapClient
{
// Default values used if no command line parameters are set private static final String
DEFAULT_HOST_URL =

"http://localhost:8080/wasp/uddi/inquiry/";
private static final String DEFAULT_DATA_FILENAME = "./Default.xml";
// In the SOAP chapter, we used "urn:oreilly:jaws:samples",
// butSystinet UDDI requires this to be blank.
private static final String URI = "";

This study source was downloaded by 100000832295719 from CourseHero.com on 08-29-2022 08:52:48 GMT -05:00

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/
private String m_hostURL;
private String m_dataFileName;
publicUDDISoapClient(String hostURL, String dataFileName) throws Exception
{
m_hostURL = hostURL;
m_dataFileName = dataFileName;
System.out.println( );
System.out.println(" ");
System.out.println("Starting UDDISoapClient:");
System.out.println(" host url = " + m_hostURL);
System.out.println(" data file = " + m_dataFileName);
System.out.println(" ");
System.out.println( );
}
public void sendSOAPMessage( ) {
try {
// Get soap body to include in the SOAP envelope from FILE FileReaderfr = new FileReader
(m_dataFileName); javax.xml.parsers.DocumentBuilderxdb =
org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder( ); org.w3c.dom.Document doc
=xdb.parse (new org.xml.sax.InputSource (fr));
if (doc == null) {
throw new org.apache.soap.SOAPException
(org.apache.soap.Constants.FAULT_CODE_CLIENT, "parsing error");
}
// Create a vector for collecting the body elements Vector bodyElements = new Vector( );
// Parse XML element as soap body element bodyElements.add(doc.getDocumentElement ( ));
// Create the SOAP envelope
org.apache.soap.Envelope envelope = new org.apache.soap.Envelope( );
envelope.declareNamespace("idoox", "http://idoox.com/uddiface"); envelope.declareNamespace("ua",
"http://idoox.com/uddiface/account"); envelope.declareNamespace("config",
"http://idoox.com/uddiface/config");

This study source was downloaded by 100000832295719 from CourseHero.com on 08-29-2022 08:52:48 GMT -05:00

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/
envelope.declareNamespace("attr", "http://idoox.com/uddiface/attr");
envelope.declareNamespace("fxml", "http://idoox.com/uddiface/formxml");
envelope.declareNamespace("inner", "http://idoox.com/uddiface/inner");
envelope.declareNamespace("", "http://idoox.com/uddiface/inner");
envelope.declareNamespace("uddi", "urn:uddi-org:api_v2");
//
// NO SOAP HEADER ELEMENT AS SYSTINET WASP DOES NOT REQUIRE IT
//
// Create the SOAP body element
org.apache.soap.Body body = new org.apache.soap.Body( );
body.setBodyEntries(bodyElements); envelope.setBody(body);
// Build and send the Message. org.apache.soap.messaging.Messagemsg =
neworg.apache.soap.messaging.Message( );
msg.send (new java.net.URL(m_hostURL), URI, envelope); System.out.println("Sent SOAP
Message with Apache HTTP SOAP Client.");
// Receive response from the transport and dump it to the screen System.out.println("Waiting
for response. "); org.apache.soap.transport.SOAPTransportst = msg.getSOAPTransport (
);
BufferedReaderbr = st.receive ( );
if(line == null) {
System.out.println("HTTP POST was unsuccessful. \n");
} else {
while (line != null) { System.out.println (line); line = br.readLine( );
}
}
/////
// Version in examples has XML pretty printing logic here.
////
} catch(Exception e) {
e.printStackTrace( );
}

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/
This study source was downloaded by 100000832295719 from CourseHero.com on 08-29-2022 08:52:48 GMT -05:00

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/
}
//
// NOTE: the remainder of this deals with reading arguments
//
/** Main program entry point. */
public static void main(String args[]) {
// Not Relevant
}
}

This study source was downloaded by 100000832295719 from CourseHero.com on 08-29-2022 08:52:48 GMT -05:00

https://www.coursehero.com/file/73848000/18bcs8004-ex2pdf/

You might also like