Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
prikladnoe6.docx
Скачиваний:
0
Добавлен:
01.07.2025
Размер:
109.28 Кб
Скачать

1.3 Файл StudentInfo.Wsdl

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.stu.cn.ua/StudentService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StudentService" targetNamespace="http://www.stu.cn.ua/StudentService/">

<wsdl:types>

<xsd:schema targetNamespace="http://www.stu.cn.ua/StudentService/">

<xsd:element name="NewOperationResponse" type="tns:StudentInfo" />

<xsd:element name="NewOperationRequest" type="xsd:string"/>

<xsd:complexType name="StudentInfo">

<xsd:sequence>

<xsd:element name="Name" type="xsd:string"></xsd:element>

<xsd:element name="female" type="xsd:string"></xsd:element>

<xsd:element name="NumID" type="xsd:string"></xsd:element>

</xsd:sequence></xsd:complexType>

</xsd:schema>

</wsdl:types>

<wsdl:message name="NewOperationResponse">

<wsdl:part element="tns:NewOperationResponse" name="NewOperationResponse"/>

</wsdl:message>

<wsdl:message name="NewOperationRequest">

<wsdl:part element="tns:NewOperationRequest" name="NewOperationRequest"/>

</wsdl:message>

<wsdl:portType name="StudentService">

<wsdl:operation name="NewOperation">

<wsdl:input message="tns:NewOperationRequest"/>

<wsdl:output message="tns:NewOperationResponse"/>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="StudentServiceSOAP" type="tns:StudentService">

<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="NewOperation">

<soap:operation soapAction="http://www.stu.cn.ua/StudentService/NewOperation"/>

<wsdl:input>

<soap:body use="literal"/>

</wsdl:input>

<wsdl:output>

<soap:body use="literal"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="StudentService">

<wsdl:port binding="tns:StudentServiceSOAP" name="StudentServiceSOAP">

<soap:address location="http://www.stu.cn.ua/"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

1.4. Класс DataBaseMyClass

package ua.cn.stu.www.StudentService;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

public class DataBaseMyClass {

private Connection con;

public DataBaseMyClass() {

try {

Class.forName("org.postgresql.Driver");

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public Connection getCon() {

if(con == null)

try {

con =

DriverManager.getConnection("jdbc:postgresql://localhost:5432/Prikladnoe", "postgres", "avatar");

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return con;

}

public StudentInfo getStudentByNum(String numID) {

StudentInfo inf = new StudentInfo();

Statement st = null;

ResultSet res = null;

try {

st = getCon().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try {

res = st.executeQuery("SELECT * FROM \"Students\" p WHERE p.\"NumID\" = " + f1(numID) + ";");

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try {

res.afterLast();

res.previous();

inf.setNumID(res.getString("NumID"));

inf.setName(res.getString("name"));

inf.setFemale(res.getString("female"));

//st.close();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return inf;

}

private String f1(String str){

return "'" + str + "'";

}

}

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]