⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stockclient.java

📁 online railway reservation using xml soap
💻 JAVA
字号:
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import java.rmi.*;
import java.sql.*;
import java.io.*;
import java.lang.*;

public class StockClient {

  public static void main(String[] args) throws Exception {
int n=0;
    URL url = new URL ("http://localhost:8080/soap/servlet/rpcrouter");
do
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("           \n");
System.out.println("******************************************************");
System.out.println("           INVENTORY MANAGEMENT SYSTEM");
System.out.println("******************************************************");
System.out.println("           \n");
System.out.println("             1.Retrieve Item");
System.out.println("             2.Insert Item");
System.out.println("             3.EXIT");


      System.out.println("Enter ur choice: ");
try{

        n = Integer.parseInt(br.readLine());

	String str1,str2,str3,str4,str5,str6,str7;
        int s1,s2,s3;

     switch(n)
     {
      case 2: 

            
System.out.println("Enter the itemcode,itemname,unit,minimum level,rate");
                  str1 = br.readLine();
                  str2 = br.readLine();
                  
                 str3 = br.readLine();
		s1=Integer.parseInt(str3);

		str4=br.readLine();
		s2=Integer.parseInt(str4);

		str5=br.readLine();
		s3=Integer.parseInt(str5);


/*str6=br.readLine();
int x=Integer.parseInt(str6);
str7=br.readLine();*/




    // Build the call.
    Call call = new Call();
    call.setTargetObjectURI("urn:stock");
    call.setMethodName("insertion");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    Vector params = new Vector();
    params.addElement(new Parameter("itemcode", String.class, str1, null));
params.addElement(new Parameter("itemname", String.class, str2, null));
params.addElement(new Parameter("unit", Integer.class, str3, null));
params.addElement(new Parameter("minlevel", Integer.class, str4, null));
params.addElement(new Parameter("rate", Integer.class, str5, null));
/*params.addElement(new Parameter("tno", Integer.class, x, null));
params.addElement(new Parameter("cla", String.class, str7, null));*/
   call.setParams (params);

    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp = call.invoke(url, "" );

    // Check the response.
    if ( resp.generatedFault() ) {

      Fault fault = resp.getFault ();
      System.out.println("The call failed: ");
      System.out.println("Fault Code   = " + fault.getFaultCode());
      System.out.println("Fault String = " + fault.getFaultString());
    }
    else {

      Parameter result = resp.getReturnValue();
      System.out.println(result.getValue());
break;
    }

  



   /*case 1:
  
String s1;

/* System.out.println("Enter Source from the following");
String sr=" Chennai		Pondicherry		Vellore";           	
System.out.println(sr);*/

System.out.println("Enter the Item Code:\n");

s1=br.readLine();

/*System.out.println("Source " + s1);
System.out.println("Enter Destination from the following");
System.out.println(" Chidambaram      Hyderabad		Delhi  ");
s2=br.readLine();

System.out.println("destination is " + s2);*/

if((s1.equals("chennai") || s1.equals("pondicherry") || s1.equals("vellore")) && (s2.equals("chidambaram") || s2.equals("hyderabad") || s2.equals("delhi")))
{

// Build the call.
    Call call1 = new Call();
    call1.setTargetObjectURI("urn:mahendra");
    call1.setMethodName("retrieve");
    call1.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    Vector params1 = new Vector();
    params1.addElement(new Parameter("d1", String.class, s1, null));
params1.addElement(new Parameter("d2", String.class, s2, null));
call1.setParams (params1);
    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp1 = call1.invoke(url, "" );

    // Check the response.
    if ( resp1.generatedFault() ) 
{
      Fault fault = resp1.getFault ();
      System.out.println("The call failed: ");
      System.out.println("Fault Code   = " + fault.getFaultCode());
      System.out.println("Fault String = " + fault.getFaultString());
    }
else 
{

      Parameter result = resp1.getReturnValue();
System.out.println("TRAINNO TRAINNAME    Source DESTINATION");
      System.out.println(result.getValue());
break;
}

}
else
{
System.out.println("Train is not available");
break;
}
*/



case 1:

  String d1;
int xz;





System.out.println("Enter the Item Code : \n ");
d1=br.readLine();


/*System.out.println("Enter rain number");
xz=Integer.parseInt(br.readLine());*/


Call call2 = new Call();

    call2.setTargetObjectURI("urn:stock");
    call2.setMethodName("retrieve");
    call2.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    Vector params2 = new Vector();
    params2.addElement(new Parameter("itemcode", String.class, d1, null));
/*params2.addElement(new Parameter("tno", Integer.class, xz, null));*/
   call2.setParams (params2);
    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp2 = call2.invoke(url, "" );

    // Check the response.
    if ( resp2.generatedFault() ) 
{
      Fault fault = resp2.getFault ();
      System.out.println("The call failed: ");
      System.out.println("Fault Code   = " + fault.getFaultCode());
      System.out.println("Fault String = " + fault.getFaultString());
    }
else 
{

      Parameter result = resp2.getReturnValue();
System.out.println("ITEM NAME  UNIT  MINIMUM LEVEL  RATE");
      System.out.println(result.getValue());
break;

}


/*case 4:





int p;
System.out.println("Enter PNR");
p=Integer.parseInt(br.readLine());

Call call3 = new Call();
    call3.setTargetObjectURI("urn:mahendra");
    call3.setMethodName("status");
    call3.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    Vector params3 = new Vector();
    
params3.addElement(new Parameter("x", Integer.class, p, null));
call3.setParams (params3);
    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp3 = call3.invoke(url, "" );

    // Check the response.
    if ( resp3.generatedFault() ) 
{
      Fault fault = resp3.getFault ();
      System.out.println("The call failed: ");
      System.out.println("Fault Code   = " + fault.getFaultCode());
      System.out.println("Fault String = " + fault.getFaultString());
    }
else 
{

      Parameter result = resp3.getReturnValue();
System.out.println("  NAME   SOURCE DESTINATION ADDRESS   PNR DATE OF JOURNEY TRAIN NUMBER CLASS");
      System.out.println(result.getValue());
break;
}*/

case 3:
System.exit(0);

}

}
catch(Exception e)
{
System.out.println(e);
}
}while(n<=3);
}
}
             
    



































⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -