Excel 如何在wsdl中传递参数

Excel 如何在wsdl中传递参数,excel,web-services,wsdl,Excel,Web Services,Wsdl,下面的类将从参数中读取输入并读取相应的excel工作表,最后将从excel返回数据集 @WebService public class ReadExcelData { @SuppressWarnings( { }) public String nameDisplay(String date, String shiftNo, String userName, String pwd) throws IOException, Pro

下面的类将从参数中读取输入并读取相应的excel工作表,最后将从excel返回数据集

 @WebService 
 public class ReadExcelData { 

    @SuppressWarnings( { }) 
    public String nameDisplay(String date, String shiftNo, String userName, 
                    String pwd) throws IOException, PropertyException, JAXBException { 
            String xmlValues = null; 
            System.out.println("Inside the webservice call"); 
            String filename = "D:\\final.xls"; 
            String dateToCheck = date; 
            String shiftNumber = shiftNo; 
            System.out.println("Date-->" + dateToCheck + "Shift number-->" 
                            + shiftNumber); 
            String userNameLogin = userName; 
            String password = pwd; 
            if ((userNameLogin.equalsIgnoreCase("DEVA")) 
                            && (password.equalsIgnoreCase("DEVA"))) { 
                    FileInputStream file = new FileInputStream(new File(filename)); 
                    HSSFWorkbook workbook = new HSSFWorkbook(file); 
                    HSSFSheet sheet = workbook.getSheetAt(0); 
                    Iterator<Row> rowItr = sheet.iterator(); 
                    while (rowItr.hasNext()) { 
                            HSSFRow row = (HSSFRow) rowItr.next(); 
                            String dateToCheckExcel = row.getCell(0).getStringCellValue(); 
                            String shiftNumberExcel = row.getCell(1).getStringCellValue(); 
                            if (dateToCheckExcel.equalsIgnoreCase(dateToCheck)) { 
                                    if (shiftNumberExcel.equalsIgnoreCase(shiftNumber)) { 
                                            StAnomaliaUTE StAnomaliaUTE = new StAnomaliaUTE(); 
                                            StAnomaliaUTE.setCodStabilimento(row.getCell(2).getStringCellValue()); 
                                            StAnomaliaUTE.setCodModello(row.getCell(3).getStringCellValue()); 
                                            StAnomaliaUTE.setCodVersione(row.getCell(4).getStringCellValue()); 
                                            StAnomaliaUTE.setCodSerie(row.getCell(5).getStringCellValue()); 
                                            StAnomaliaUTE.setCodAreaUnita(row.getCell(6).getStringCellValue()); 
                                            StAnomaliaUTE.setNumUte(row.getCell(7).getStringCellValue()); 
                                            StAnomaliaUTE.setNumLinea(row.getCell(8).getStringCellValue()); 
                                            StAnomaliaUTE.setNumDominio(row.getCell(9).getStringCellValue()); 
                                            StAnomaliaUTE.setCodComponente(row.getCell(10).getStringCellValue()); 
                                            StAnomaliaUTE.setCodColore(row.getCell(11).getStringCellValue()); 
                                            StAnomaliaUTE.setCodAnomalia(row.getCell(12).getStringCellValue()); 
                                            StAnomaliaUTE.setCodPosizione(row.getCell(13).getStringCellValue()); 
                                            StAnomaliaUTE.setCodTipologia(row.getCell(14).getStringCellValue()); 
                                            StAnomaliaUTE.setDataRilevamento(row.getCell(15).getStringCellValue()); 
                                            StAnomaliaUTE.setDataRisoluzione(row.getCell(16).getStringCellValue()); 
                                            StAnomaliaUTE.setNumeroCasi(Integer.parseInt(row.getCell(17).getStringCellValue())); 
                                            StAnomaliaUTE.setTotaleVetture(Integer.parseInt(row.getCell(18).getStringCellValue())); 
                                            DataSet dataSet = new DataSet(); 
                                            dataSet.setDataset(new ArrayList<StAnomaliaUTE>()); 
                                            dataSet.getDataset().add(StAnomaliaUTE); 
                                            xmlValues = DataSetXmlGenerator.getSerializedDataSet(dataSet); 
                                    } 
                            } 

                    } 

            } 
            return xmlValues; 

    } 
  } 
当我在浏览器中点击URL时,我得到了下面的XML模式

  <?xml version="1.0" encoding="UTF-8" ?> 
  - <!-- 
   Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. 
    --> 
  - <!-- 
   Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.6 in JDK 6. 
    --> 
  - <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://helper.chrysler.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://helper.chrysler.com/" name="ReadExcelDataService"> 
  - <types> 
  - <xsd:schema> 
    <xsd:import namespace="http://helper.chrysler.com/" schemaLocation="http://localhost:9111/PFSWebServices/ReadExcel?xsd=1" /> 
    </xsd:schema> 
    </types> 
  - <message name="nameDisplay"> 
    <part name="parameters" element="tns:nameDisplay" /> 
    </message> 
  - <message name="nameDisplayResponse"> 
    <part name="parameters" element="tns:nameDisplayResponse" /> 
    </message> 
  - <message name="IOException"> 
    <part name="fault" element="tns:IOException" /> 
    </message> 
  - <message name="PropertyException"> 
    <part name="fault" element="tns:PropertyException" /> 
    </message> 
  - <message name="JAXBException"> 
    <part name="fault" element="tns:JAXBException" /> 
    </message> 
  - <portType name="ReadExcelData"> 
  - <operation name="nameDisplay"> 
    <input message="tns:nameDisplay" /> 
    <output message="tns:nameDisplayResponse" /> 
    <fault message="tns:IOException" name="IOException" /> 
    <fault message="tns:PropertyException" name="PropertyException" /> 
    <fault message="tns:JAXBException" name="JAXBException" /> 
    </operation> 
    </portType> 
  - <binding name="ReadExcelDataPortBinding" type="tns:ReadExcelData"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> 
  - <operation name="nameDisplay"> 
    <soap:operation soapAction="" /> 
  - <input> 
    <soap:body use="literal" /> 
    </input> 
  - <output> 
    <soap:body use="literal" /> 
    </output> 
  - <fault name="IOException"> 
    <soap:fault name="IOException" use="literal" /> 
    </fault> 
  - <fault name="PropertyException"> 
    <soap:fault name="PropertyException" use="literal" /> 
    </fault> 
  - <fault name="JAXBException"> 
    <soap:fault name="JAXBException" use="literal" /> 
    </fault> 
    </operation> 
    </binding> 
  - <service name="ReadExcelDataService"> 
  - <port name="ReadExcelDataPort" binding="tns:ReadExcelDataPortBinding"> 
    <soap:address location="http://localhost:9111/PFSWebServices/ReadExcel" /> 
    </port> 
    </service> 
    </definitions> 
但是我得到了400服务器错误

让我知道我是否错误地传递了参数


请帮助我解决此错误。

这是一个SOAP服务。您必须创建客户机或发送如下SOAP消息。SOAP正文将包含实际的文档w.r.t到XML模式

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bal="http://www.i2c.com/mcpws/BalanceInquiry/">
   <soapenv:Header/>
   <soapenv:Body>

       <nameDisplay>
               ..........
      </nameDisplay>

   </soapenv:Body>
</soapenv:Envelope>

..........
对于测试,您可以使用soapui工具。下载后,创建一个新的soapui项目并提供上述WSDL文件路径。它将为您生成示例请求,您也可以执行这些请求

http://localhost:9111/PFSWebServices/ReadExcel/nameDisplay?date="19900627"&shiftNo="2"&userName="deva"&pwd="deva" 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bal="http://www.i2c.com/mcpws/BalanceInquiry/">
   <soapenv:Header/>
   <soapenv:Body>

       <nameDisplay>
               ..........
      </nameDisplay>

   </soapenv:Body>
</soapenv:Envelope>