佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 922|回复: 0

JAVA web service 的问题 - how to send in more parameters

[复制链接]
发表于 13-9-2011 11:22 AM | 显示全部楼层 |阅读模式

1. 我是用eclipse Helios 写了以下的java class。


  1. //WebService1.java
  2. package test;

  3. public class WebService1 {

  4.         public class NumbersBean {
  5.                 public float num1;
  6.                 public float num2;
  7.         }
  8.         
  9.         public float servSummation (NumbersBean nBean)
  10.         {
  11.                 float ans = 0;
  12.                 try {
  13.                         ans = nBean.num1 + nBean.num2;
  14.                 } catch (Exception e) {
  15.                 }
  16.                 return ans;
  17.         }

  18. }
复制代码


2. 之后我right click 以上的文件,点击Web Services/Create Web Service。Web service type 我选 Bottom up Java Web Service, 下面的两个图分别选Start service 和 No client。


3. 完成之后,我right click project folder at eclipse,点击Run As/ Run on server。从中再点击几个link,我就得到以下的wsdl file。


  1. //WebService1.wsdl
  2. <?xml version="1.0" encoding="UTF-8" ?>
  3. - <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://test" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ax21="http://test/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://test">
  4.   <wsdl:documentation>Please Type your service description here</wsdl:documentation>
  5. - <wsdl:types>
  6. - <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test/xsd">
  7. - <xs:complexType name="WebService1_NumbersBean">
  8.   <xs:sequence />
  9.   </xs:complexType>
  10.   </xs:schema>
  11. - <xs:schema xmlns:ax22="http://test/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test">
  12.   <xs:import namespace="http://test/xsd" />
  13. - <xs:element name="servSummation">
  14. - <xs:complexType>
  15. - <xs:sequence>
  16.   <xs:element minOccurs="0" name="nBean" nillable="true" type="ax21:WebService1_NumbersBean" />
  17.   </xs:sequence>
  18.   </xs:complexType>
  19.   </xs:element>
  20. - <xs:element name="servSummationResponse">
  21. - <xs:complexType>
  22. - <xs:sequence>
  23.   <xs:element minOccurs="0" name="return" type="xs:float" />
  24.   </xs:sequence>
  25.   </xs:complexType>
  26.   </xs:element>
  27.   </xs:schema>
  28.   </wsdl:types>
  29. - <wsdl:message name="servSummationRequest">
  30.   <wsdl:part name="parameters" element="ns:servSummation" />
  31.   </wsdl:message>
  32. - <wsdl:message name="servSummationResponse">
  33.   <wsdl:part name="parameters" element="ns:servSummationResponse" />
  34.   </wsdl:message>
  35. - <wsdl:portType name="WebService1PortType">
  36. - <wsdl:operation name="servSummation">
  37.   <wsdl:input message="ns:servSummationRequest" wsaw:Action="urn:servSummation" />
  38.   <wsdl:output message="ns:servSummationResponse" wsaw:Action="urn:servSummationResponse" />
  39.   </wsdl:operation>
  40.   </wsdl:portType>
  41. - <wsdl:binding name="WebService1Soap11Binding" type="ns:WebService1PortType">
  42.   <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
  43. - <wsdl:operation name="servSummation">
  44.   <soap:operation soapAction="urn:servSummation" style="document" />
  45. - <wsdl:input>
  46.   <soap:body use="literal" />
  47.   </wsdl:input>
  48. - <wsdl:output>
  49.   <soap:body use="literal" />
  50.   </wsdl:output>
  51.   </wsdl:operation>
  52.   </wsdl:binding>
  53. - <wsdl:binding name="WebService1Soap12Binding" type="ns:WebService1PortType">
  54.   <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
  55. - <wsdl:operation name="servSummation">
  56.   <soap12:operation soapAction="urn:servSummation" style="document" />
  57. - <wsdl:input>
  58.   <soap12:body use="literal" />
  59.   </wsdl:input>
  60. - <wsdl:output>
  61.   <soap12:body use="literal" />
  62.   </wsdl:output>
  63.   </wsdl:operation>
  64.   </wsdl:binding>
  65. - <wsdl:binding name="WebService1HttpBinding" type="ns:WebService1PortType">
  66.   <http:binding verb="POST" />
  67. - <wsdl:operation name="servSummation">
  68.   <http:operation location="servSummation" />
  69. - <wsdl:input>
  70.   <mime:content type="text/xml" part="parameters" />
  71.   </wsdl:input>
  72. - <wsdl:output>
  73.   <mime:content type="text/xml" part="parameters" />
  74.   </wsdl:output>
  75.   </wsdl:operation>
  76.   </wsdl:binding>
  77. - <wsdl:service name="WebService1">
  78. - <wsdl:port name="WebService1HttpSoap11Endpoint" binding="ns:WebService1Soap11Binding">
  79.   <soap:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpSoap11Endpoint/" />
  80.   </wsdl:port>
  81. - <wsdl:port name="WebService1HttpSoap12Endpoint" binding="ns:WebService1Soap12Binding">
  82.   <soap12:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpSoap12Endpoint/" />
  83.   </wsdl:port>
  84. - <wsdl:port name="WebService1HttpEndpoint" binding="ns:WebService1HttpBinding">
  85.   <http:address location="http://localhost:8081/TestJavaWebService/services/WebService1.WebService1HttpEndpoint/" />
  86.   </wsdl:port>
  87.   </wsdl:service>
  88.   </wsdl:definitions>
复制代码


4. 我发现wsdl file里并没有num1和num2。那么我怎样pass in num1 和 num2 的数据呢?






希望能得到大大们的帮助,在下感激不尽了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 11-11-2025 07:27 PM , Processed in 0.097431 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表