0
votes

I've created a simple HelloWorldWS project to run on Tomcat 7 with Metro 2.2. I have installed the metro libraries using the ant script on my local tomcat server. I have also added the libraries to an endorsed folder I have created in my JDK + JRE within the JDK. JDK(1.7.0 64 bit)

Here is a snippet of the web service class:

package za.co.atheba.ws;

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 class Customer {
    @WebMethod
    public String hello(final String name){
        return "Hello " +name;
    }

}

I have added the ws servlet in web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <listener>
        <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
    </listener>

    <servlet>
        <description>JAX-WS endpoint</description>
        <display-name>WSServlet</display-name>
        <servlet-name>WSServlet</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>WSServlet</servlet-name>
        <!--
            The url-pattern gets appended to the application's root context which is the name of the .war.
            If the war is packaged in HugeWebServices.war and the url-pattern is set to <url-pattern>/webservices/*</url-pattern>,
            then the servlet context/url will be host:port/HugeWebServices/webservices.
        -->
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>

</web-app>

And wired this up to sun-jaxws.xml:

<?xml version="1.0" encoding="UTF-8"?>

<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">

    <endpoint
        name="CustomerService"
        implementation="za.co.atheba.ws.Customer"
        wsdl="WEB-INF/wsdl/CustomerService.wsdl"
        url-pattern="/CustomerService"/>


</endpoints>

I package as .war and deply to Tomcat successfully. I can view the wsdl correctly...

I tried to test against the web service using eclipse web service explorer but the operation returns "IWAB0135E An unexpected error has occurred. java.net.SocketException Software caused connection abort: recv failed"

I then tried calling wsimport on the wsdl to generate client artifacts but received this error:

[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):

 At least one WSDL with at least one service definition needs to be provided.


Exception in thread "main" javax.xml.stream.FactoryConfigurationError: Provider
com.ctc.wstx.stax.WstxInputFactory not found
        at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:163)
        at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
        at javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136
)
        at com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory.getXMLIn
putFactory(XMLStreamReaderFactory.java:98)
        at com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory.<clinit>
(XMLStreamReaderFactory.java:67)
        at com.sun.xml.internal.ws.api.addressing.WSEndpointReference.<init>(WSE
ndpointReference.java:157)
        at com.sun.xml.internal.ws.api.addressing.AddressingVersion.<init>(Addre
ssingVersion.java:426)
        at com.sun.xml.internal.ws.api.addressing.AddressingVersion.<init>(Addre
ssingVersion.java:57)
        at com.sun.xml.internal.ws.api.addressing.AddressingVersion$1.<init>(Add
ressingVersion.java:59)
        at com.sun.xml.internal.ws.api.addressing.AddressingVersion.<clinit>(Add
ressingVersion.java:59)
        at com.sun.tools.internal.ws.wsdl.parser.MemberSubmissionAddressingExten
sionHandler.getNamespaceURI(MemberSubmissionAddressingExtensionHandler.java:51)
        at com.sun.tools.internal.ws.wsdl.parser.WSDLParser.register(WSDLParser.
java:130)
        at com.sun.tools.internal.ws.wsdl.parser.WSDLParser.<init>(WSDLParser.ja
va:114)
        at com.sun.tools.internal.ws.processor.modeler.wsdl.WSDLModeler.buildMod
el(WSDLModeler.java:99)
        at com.sun.tools.internal.ws.wscompile.WsimportTool.run(WsimportTool.jav
a:178)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:120)
        at com.sun.tools.internal.ws.WsImport.main(WsImport.java:42)

I have tried two approaches 1) allowing jax-ws to generate a wsdl & 2) Using wsgen to create a wsdl from code that I have written.

Here is the wsdl:

<!--
 Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.2.1-1 (tags/2.2.1-1-7267; 2012-08-30T14:04:51+0000) JAXWS-RI/2.2.7 JAXWS/2.2 svn-revision#unknown. 
-->
<!--  WSgen created wsdl  -->
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://ws.atheba.co.za/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" targetNamespace="http://ws.atheba.co.za/" name="CustomerService">
<types>
<xsd:schema>
<xsd:import namespace="http://ws.atheba.co.za/" schemaLocation="http://localhost:8080/HelloWorldWS/CustomerService?xsd=1"/>
</xsd:schema>
</types>
<message name="hello">
<part name="parameters" element="tns:hello"/>
</message>
<message name="helloResponse">
<part name="parameters" element="tns:helloResponse"/>
</message>
<portType name="Customer">
<operation name="hello">
<input wsam:Action="http://ws.atheba.co.za/Customer/helloRequest" message="tns:hello"/>
<output wsam:Action="http://ws.atheba.co.za/Customer/helloResponse" message="tns:helloResponse"/>
</operation>
</portType>
<binding name="CustomerPortBinding" type="tns:Customer">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="hello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CustomerService">
<port name="CustomerPort" binding="tns:CustomerPortBinding">
<soap:address location="http://localhost:8080/HelloWorldWS/CustomerService"/>
</port>
</service>
</definitions>

In both cases the service deploys correctly but trying to create a client against the wsdl fails. Jax-ws was supposed to be easy? Any help in the right direction will be much appreciated...

1
Resolved: Captured HTTP packets using Wireshark and realized I wasn't receiving any. localhost was going over our network proxy. Fixed proxy settings and all works as expected!!! - Atheba

1 Answers

0
votes

Resolved: Captured HTTP packets using Wireshark and realized I wasn't receiving any. localhost was going over our network proxy. Fixed proxy settings and all works as expected!!!