-
Apr 24th, 2008, 06:13 PM
#1
WebServiceTransportException: Not found [404]
I'm using Spring WS 1.5 and am having a problem with my first simple web service that simply sends a first and last name which in turn gets echoed back in a response. When I point the browser to http://localhost:7001/services/name.wsdl the wsdl renders without any problems. However, when I try to call the web service from a client program I get a WebServiceTransportException. I've read all the documentation and looked at the examples but I'm really having a tough go at this and could really use some help. Here is the WebServiceClient class
public class WebServiceClient {
private static final String MESSAGE =
"<NameRequest xlmns=\"http://mycompany.com/hr/schemas\"><FirstName>John</FirstName><LastName>Smith</LastName></NameRequest>";
private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
// send to an explicit URI
public void customSendAndReceive() {
StreamSource source = new StreamSource(new StringReader(MESSAGE));
StreamResult result = new StreamResult(System.out);
webServiceTemplate.sendSourceAndReceiveToResult("h ttp://localhost:7001/services/nameService",
source, result);
}
public static void main(String [] args) {
WebServiceClient client = new WebServiceClient();
client.customSendAndReceive();
}
}
Here is the ws-servlet.xml:
<bean id="name" class="org.springframework.ws.wsdl.wsdl11.DefaultW sdl11Definition">
<property name="schema" ref="schema" />
<property name="portTypeName" value="NameResource" />
<property name="locationUri" value="http://localhost:7001/services/nameService" />
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema ">
<property name="xsd" value="/WEB-INF/schemas/name.xsd"/>
</bean>
<bean id="nameEndpoint" class="com.sonybmg.dra.ws.NameEndpoint" />
<bean class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootQNameEndpointMapping">
<property name="mappings">
<props>
<prop key="{http://mycompany.com/hr/schemas}NameRequest">nameEndpoint</prop>
</props>
</property>
<property name="interceptors">
<bean class="org.springframework.ws.server.endpoint.inte rceptor.PayloadLoggingInterceptor" />
</property>
</bean>
Here is my EndPoint class:
public class NameEndpoint extends AbstractJDomPayloadEndpoint {
private XPath nameExpression;
public NameEndpoint() throws Exception {
Namespace namespace = Namespace.getNamespace("hr", "http://mycompany.com/hr/schemas");
nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
nameExpression.addNamespace(namespace);
}
protected Element invokeInternal(Element nameRequest) throws Exception {
String name = nameExpression.valueOf(nameRequest);
Element responseElement = new Element("NameResponse");
responseElement.setText(name);
return responseElement;
}
}
and finally the xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:hr="http://mycompany.com/hr/schemas" elementFormDefault="qualified"
targetNamespace="http://mycompany.com/hr/schemas">
<xs:element name="NameRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NameResponse" type="xs:string" />
</xs:schema>
As far as I can tell my NameEnpoint invokeInternal method is never getting called.
Please Help
Last edited by backofthecup@hotmail.com; Apr 24th, 2008 at 06:21 PM.
-
Apr 25th, 2008, 01:51 AM
#2
Could you please post the exception's full stack trace please?
-
Apr 25th, 2008, 10:01 AM
#3
Here is the full stack trace:
Exception in thread "main" org.springframework.ws.client.WebServiceTransportE xception: Not Found [404]
at org.springframework.ws.client.core.WebServiceTempl ate.handleError(WebServiceTemplate.java:561)
at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:489)
at org.springframework.ws.client.core.WebServiceTempl ate.sendAndReceive(WebServiceTemplate.java:440)
at org.springframework.ws.client.core.WebServiceTempl ate.doSendAndReceive(WebServiceTemplate.java:395)
at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:341)
at org.springframework.ws.client.core.WebServiceTempl ate.sendSourceAndReceiveToResult(WebServiceTemplat e.java:326)
at com.sonybmg.dra.ws.WebServiceClient.customSendAndR eceive(WebServiceClient.java:22)
at com.sonybmg.dra.ws.WebServiceClient.main(WebServic eClient.java:28)
-
Apr 25th, 2008, 10:11 AM
#4
You're getting a 404. Are you sure your web service template is pointing to the correct URI?
-
Apr 25th, 2008, 10:18 AM
#5
No I'm not sure I'm pointing to the correct uri. In the WebServiceClient I'm using:
webServiceTemplate.sendSourceAndReceiveToResult("h ttp://localhost:7001/services/nameService", source, result);
which is specified in "name" bean in ws-servlet.xml:
<property name="locationUri" value="http://localhost:7001/services/nameService" />
What URI should I be using?
-
Apr 25th, 2008, 11:18 AM
#6
I figured it out....I had to wrong URI. Forgot to put the app name in the uri :
http://localhost:7001/{app name}/services/nameService
Thanks for you help!
-
Jul 28th, 2009, 06:41 AM
#7
I have same problem
Can anyone tells me how this problem is solved because I gonna be crazy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules