Announcement

Collapse
No announcement yet.

WS Client mit JAX-WS

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WS Client mit JAX-WS

    Bitte helft mir,

    ich muss einen Web Service Client erstellen. Die fertigen Jar's sollen dabei möglichst klein sein. Ich habe eine WSDL Datei bekommen die ich in Eclipse WTP Web Service Explorer erfolgreich testen konnte.
    Hier die WSDL Datei:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!--Generated by calling http://192.168.1.4/dTest1Server.php?wsdl-->
    <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" 
    	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    	xmlns:tns="http://www.wso2.org/php" 
    	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    	xmlns:http="http://www.w3.org/2003/05/soap/bindings/HTTP/" 
    	xmlns:ns0="http://www.wso2.org/php/xsd" 
    	targetNamespace="http://www.wso2.org/php">
    	<types><xsd:schema targetNamespace="http://www.wso2.org/php/xsd">
    	<xsd:element name="dQuery">
    		<xsd:complexType>
    			<xsd:sequence>
    				<xsd:element name="searchStr" type="xsd:string"/>
    			</xsd:sequence>
    		</xsd:complexType>
    	</xsd:element>
    	<xsd:element name="dQueryResponse">
    		<xsd:complexType>
    			<xsd:sequence>
    						<xsd:element name="id" type="xsd:long"/>
    						<xsd:element name="Name1" type="xsd:string"/>
    						<xsd:element name="Name2" type="xsd:string"/>
    						<xsd:element name="Type1" type="xsd:string"/>		
    			</xsd:sequence>
    		</xsd:complexType>
    	</xsd:element>
    		</xsd:schema>
    			</types>
    				<message name="dQueryInput">
    					<part name="parameters" element="ns0:dQuery"/>
    				</message>
    				<message name="dQueryOutput">
    					<part name="parameters" element="ns0:dQueryResponse"/>
    				</message>
    				<portType name="dTest1Server.php">
    					<operation name="dQuery">
    						<input message="tns:dQueryInput"/>
    						<output message="tns:dQueryOutput"/>
    					</operation>
    				</portType>
    				<binding name="dTest1Server.php" type="tns:dTest1Server.php">
    					<soap:binding xmlns="http://schemas.xmlsoap.org/wsdl/soap/" 
    						transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    					<operation xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/" name="dQuery">
    						<soap:operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" 
    							soapAction="http://192.168.1.4/dTest1Server.php/dQuery" style="document"/>
    						<input xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
    							<soap:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
    						</input>
    						<output xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/">
    							<soap:body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
    						</output>
    					</operation>
    				</binding>
    				<service name="dTest1Server.php">
    					<port xmlns:default="http://schemas.xmlsoap.org/wsdl/soap/" 
    						name="dTest1Server.php" binding="tns:dTest1Server.php">
    						<soap:address xmlns="http://schemas.xmlsoap.org/wsdl/soap/" 
    							location="http://192.168.1.4/dTest1Server.php"/>
    					</port>
    				</service>
    	</definitions>
    Ich generiere den Client code mit
    Code:
    wsimport -d C:\data\WsImportTest\bin -keep -s C:\data\WsImportTest\src -p com.bTest.wsclient http://192.168.1.4/dTest1.wsdl
    Als Ergebniss bekomme ich folgende Dateien erstellt:
    dQuery.java
    dQueryResponse.java
    ObjectFactory.java
    package-info.java
    dTest1ServerPhp_Service.java
    dTest1ServerPhp.java

    Nun möchte ich in einem neuen Application Projekt diesen Web Service aufrufen und das Ergebnis (mehrere Datensätze) empfangen.

    Ich probiere bereits seit einer Woche alles Mögliche aus und komme nicht weiter. Auch die Suche im Internet bringt mich nicht weiter.

    Wer hat es schon einmal geschafft einen Web Service Client mit wsimport und wenig Jar files zu erstellen?

    Danke für Hilfe

    Ron


    Ron

  • #2
    Wer hat es schon einmal geschafft einen Web Service Client mit wsimport und wenig Jar files zu erstellen?
    Wo sollte es mehrere JARs geben, wenn du dein Eclipse-Projekt als JAR erzeugen lässt?

    Lediglich die genutzten Libs gehören dann dazu, so die die Anforderung "wenige JARs" nur dann zu erfüllen, wenn du mindestens Java 1.6. nimmt und den Webservice mit den implementierten Webservice-Klassen erstellst.

    Es gibt eine Menge Tutorials zu WebservicesCLIENTS auf Basis JAX-WS (da du diesem Import benutzt)

    http://java.sun.com/developer/techni...J2SE/jax_ws_2/
    Christian

    Comment


    • #3
      [highlight=java]
      public static void main(String[] args)
      {
      DTest1ServerPhp_Service s=new DTest1ServerPhp_Service();
      DTest1ServerPhp server=s.getDTest1ServerPhp();
      server.dQuery(.................................... ......);
      }
      [/highlight]

      Das JAR dazu ist 14kb groß. Hoffentlich nicht zuviel. Hier als ZIP:

      JavaApplication85.zip
      Christian

      Comment

      Working...
      X