.


:




:

































 

 

 

 


Web-. 1. Eclipse Europe




1. Eclipse Europe

| | Eclipse

2. Web-:

File → New → Project

. Web → Dynamic Web Project → . OK Web Development

soap_server

3. Java-, Web-:

. Package Explorer | soap_server | . . Java Resources → New → Class

University | . Finish →

public class University {

}

4. . :

import java. sql.*;

import java. io.*;

import java. util.*;

5. University

5.1 con

public Connection con()

{

}

.

5.2 (Connection)

Connection conn = null;

5.3 MySQL

try {

Class. forName("com. mysql. jdbc. Driver").newInstance();

5.4

String connectionURL = "jdbc:mysql:/ ?user= ;password= ";

5.5 (Statement):

Statement statement = null;

5.6 MySQL:

conn = DriverManager. getConnection(connectionURL, "root", "");

5.7 :

statement = conn. createStatement();

conn. setReadOnly(true);

}

catch (Exception e) {

System. out. println(e. getMessage());

}

5.8 :

return conn;

}

6. faculties, XML- ,

6.1 :

public String faculties(){

}

.

6.2 res faculties:

String res = "<faculties>";

6.3 con():

try {

Connection conn = con();

6.4. Faculty () . PHP :

ResultSet rs =

conn. createStatement().executeQuery("SELECT * FROM faculty");

6.5 XML- faculty ID name:

while (rs. next())

{

res = res + "<faculty ID='"+rs. getString("id")+"' name='"+rs. getString("name")+"'/>";

}

}

catch (Exception e) {

System. out. println(e. getMessage());

}

6.6 res faculties:

res = res + "</faculties>";

6.7 res

return res;

}

7. specialities, groups ( ) uspev ( gr ), XML- , .

8. Java Web- UniversityService:

. . University. class → New → Other

. New Wizard → . Web Services → . Web Service → . Next

. Web- ← Java Bean Web → . OK

9. WSDL- Web- UniversityService. wsdl.

Web-

1. Web- .

File → New → Web → Dynamic Web Project

name → Lab4_JSP

2. JSP-

. Project Explorer | Lab4_JSP | . . . → . New → JSP |

. New JavaServer Page | File name ← Default | HTML

3. Index. jsp .

4. WSDL- soap_server Lab4_JSP / WebContent

5. Web- WSDL-.

. . UniversityService. wsdl → New → Other

. New Wizard | . Web Services | . Web Service Client → . Next → . OK

. Java proxy → . Finish.

Java-, Java-, Web-.

6. Index. jsp

7. XML-:

<%@page import="java. sql.*"%>

<%@page import="java. io.*"%>

<%@page import="java. util.*"%>

<%@ page import="javax. xml. parsers. DocumentBuilderFactory"%>

<%@ page import="javax. xml. parsers. DocumentBuilder"%>

<%@ page import="org. w3c. dom.*"%>

<%@ page import="javax. xml. parsers.*"%>

<%@ page import="javax. xml. transform.*"%>

<%@ page import="javax. xml. transform. dom.*"%>

<%@ page import="javax. xml. transform. stream.*"%>

8. Java- (UniversityProxy uni), Web-:

<%@page import="uni. UniversityProxy"%>

9. UniversityProxy Web-:

UniversityProxy proxy = new UniversityProxy();

10. DocumentBuilderFactory:

DocumentBuilderFactory dbf = DocumentBuilderFactory. newInstance();

11. DocumentBuilderFactory DOM-:

DocumentBuilder db = dbf. newDocumentBuilder();

12. Reader Web- faculties, :

Reader reader=new CharArrayReader(proxy. faculties().toCharArray());

13. Document DOM- Reader:

Document faculty = db. parse(new org. xml. sax. InputSource(reader));

14. XML-, DOM- faculty :

Element fac = faculty. getDocumentElement();

15. DOM-, , XML-, .

16. XML- fac:

16.1 XML- fac:

<%

NodeList childNodes = fac. getChildNodes();

if (childNodes!= null)

{

for (int x=0; x<childNodes. getLength(); x++)

{

16.2 id name XML-:

NamedNodeMap facs = childNodes. item(x).getAttributes();

String id = facs. item(0).getNodeValue();

String name = facs. item(1).getNodeValue();

%>

16.3 id :

<option value="

<%

out. println(id);

%>

">

16.4 name :

<%

out. println(name);

%>

</option>

<%

}

}

%>

17. .

18. Browse. jsp . Web- soap_server uspev ( ).

19. Web-. Eclipse

Project → Run as → Run on Server

1. -?

2. -?

3. SOAP-?

4. UDDI?

5. -?

:

, ;

;

Web- ;

.

 

: http://pandia.ru/text/78/546/88379.php [14.03.2016]

 





:


: 2017-04-14; !; : 324 |


:

:

, .
==> ...

1369 - | 1276 -


© 2015-2024 lektsii.org - -

: 0.017 .