Java endpoint - perl consumer web service -
i've problem calling java endpoint (code below) perl client (activeperl 5.16). code snippets book java web services , running
package ch01.ts; import javax.jws.webmethod; import javax.jws.webservice; import javax.jws.soap.soapbinding; import javax.jws.soap.soapbinding.style; @webservice @soapbinding(style=style.rpc) public interface timeserver { @webmethod string gettimeasstring(); @webmethod long gettimeaselapsed(); }
package ch01.ts; import java.util.date; import javax.jws.webservice; @webservice(endpointinterface="ch01.ts.timeserver") public class timeserverimpl implements timeserver { public string gettimeasstring() { return new date().tostring(); } public long gettimeaselapsed() { return new date().gettime(); } }
package ch01.ts; import javax.xml.ws.endpoint; public class timeserverpublisher { public static void main(string[] args) { endpoint.publish("http://127.0.0.1:9876/ts", new timeserverimpl()); } }
and perl consumer:
use soap::lite; $url = 'http://127.0.0.1:9876/ts?wsdl'; $service = soap::lite->service($url); print "\ncurrent time is: ",$service->gettimeasstring(); print "\nelapsed miliseconds epoch: ", $service->gettimeaselapsed();
when i'm calling web service i'm having stack trace:
maj 04, 2013 10:21:40 com.sun.xml.internal.ws.transport.http.httpadapter$httptoolkit handle severe: couldn't create soap message. expecting envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, got http://schemas.xmlsoap.org/wsdl/soap/ com.sun.xml.internal.ws.protocol.soap.versionmismatchexception: couldn't create soap message. expecting envelope in namespace http://schemas.xmlsoap.org/soap/envelope/, got http://schemas.xmlsoap.org/wsdl/soap/ @ com.sun.xml.internal.ws.encoding.streamsoapcodec.decode(unknown source)
i think soap version problem, above example 1.1, when i've change client code
my $service = soap::lite->service($url)->soapversion('1.2');
then different error throw
com.sun.xml.internal.ws.server.unsupportedmediaexception: unsupported content-type: application/soap+xml; charset=utf-8 supported ones are: [text/xml]
i need either dealing envelope problem or content-type. grateful directions, code , else help.
i not quite sure of perl->soap api, first case client version 1.1 may need mention namespace somewhere.
may like
server->setnamespace() //or soap::lite->service($url,"<namespace>"); //please search perl web service client examples
and second case(1.2) service expecting text , api sends soap encoding or something.
refer http://www.herongyang.com/web-services/perl-soap-1-2-unsupported-media-type-application-soap.html
this may helpful
$client = soap::lite->new() ->soapversion('1.2') ->envprefix('soap12') ->default_ns('http://xmlme.com/webservices') ->on_action( sub {join '/', @_} ) ->readable(true) ->proxy('http://www.xmlme.com/wsshakespeare.asmx');
and
http://www.herongyang.com/web-services/perl-soap-1-2-request-differences-soap-1-1-and-1-2.html
hope helps
Comments
Post a Comment