Habe folgenden Webservice geschrieben:
Diesen Webservice habe ich deployed und bekomme nach dem Aufruf von:
Jetzt hab ich mir nen Client dazu geschrieben:
Dieser Client liefert mir die folgende Ausgabe:
Wieso??
:bahnhof:
Sorry, ich weiß das das weng viel Code auf einmal ist.
Aber wenn ich eine Chance haben will eine Antwort auf meine Frage zu bekommen muss das woll sein.
Code:
package jwsMitAxis.bookstore;
public class Book
{
private String title;
private String author;
public Book(String title, String author){
this.title = title;
this.author = author;
}
public String getTitle(){return title;}
public void setTitle(String title){this.title = title;}
public String getAuthor(){return author;}
public void setAuthor(String author){this.author = author;}
}
Code:
package jwsMitAxis.bookstore;
public class Store
{
private Book book = new Book("title", "author");
public Book getBookDetails(){return book;}
}
Code:
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Bookstore" provider="java:RPC">
<parameter name="className" value="jwsMitAxis.bookstore.Store"/>
<parameter name="allowedMethods" value="*"/>
<typeMapping qname="myNS:Book" xmlns:myNS="http://bookstore.jwsMitAxis"
languageSpecificType="java:jwsMitAxis.bookstore.Book"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</service>
</deployment>
Diesen Webservice habe ich deployed und bekomme nach dem Aufruf von:
auch das richtigelocalhost:8080/axis/services/Bookstore?method=getBookDetails
zurück.<soapenv:Envelope>
-
<soapenv:Body>
-
<getBookDetailsResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<getBookDetailsReturn href="#id0"/>
</getBookDetailsResponse>
-
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns1:Book">
<author xsi:type="soapenc:string">author</author>
<title xsi:type="soapenc:string">title</title>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
Jetzt hab ich mir nen Client dazu geschrieben:
Code:
package jwsMitAxis.bookstore;
import org.apache.axis.client.*;
import org.apache.axis.encoding.ser.*;
import java.net.URL;
import javax.xml.rpc.encoding.XMLType;
import javax.xml.rpc.ParameterMode;
import javax.xml.namespace.QName;
import jwsMitAxis.dvd.Movie;
public class StoreClient
{
public static void main(String[] args)
{
try
{
String endpoint = "http://localhost:8080/axis/services/Bookstore";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new URL(endpoint));
call.setOperationName("getBookDetails");
QName qnBook = new QName("http://bookstore.jwsMitAxis", "Book");
call.registerTypeMapping(Book.class, qnBook,
new BeanSerializerFactory(Book.class, qnBook),
new BeanDeserializerFactory(Book.class, qnBook));
Book bookDetails = (Book)call.invoke(new Object[] {});
System.out.println("Buch:\t" + bookDetails.getTitle());
System.out.println("Author:\t" + bookDetails.getAuthor());
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Dieser Client liefert mir die folgende Ausgabe:
Buch: author
Author: author
Wieso??
:bahnhof:
Sorry, ich weiß das das weng viel Code auf einmal ist.
Aber wenn ich eine Chance haben will eine Antwort auf meine Frage zu bekommen muss das woll sein.