SWS-249
This commit is contained in:
2
samples/pox/client/curl/client.sh
Executable file
2
samples/pox/client/curl/client.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
curl --header "Content-type: application/xml" -v --data @contactsRequest.xml http://localhost:8080/pox/
|
||||
11
samples/pox/client/curl/contactsRequest.xml
Normal file
11
samples/pox/client/curl/contactsRequest.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Contacts xmlns="http://www.springframework.org/spring-ws/samples/pox">
|
||||
<Contact>
|
||||
<Name>John Doe</Name>
|
||||
<Phone>626-555-3456</Phone>
|
||||
</Contact>
|
||||
<Contact>
|
||||
<Name>Jane Doe</Name>
|
||||
<Phone>626-555-6543</Phone>
|
||||
</Contact>
|
||||
</Contacts>
|
||||
46
samples/pox/client/spring-ws/build.xml
Normal file
46
samples/pox/client/spring-ws/build.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="spring-ws-pox-sample-spring-ws-client" default="build" xmlns:artifact="urn:maven-artifact-ant">
|
||||
<property name="bin.dir" value="bin"/>
|
||||
<property name="src.dir" value="src"/>
|
||||
|
||||
<target name="init">
|
||||
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/../../../maven-ant-tasks-2.0.7.jar"/>
|
||||
</classpath>
|
||||
</typedef>
|
||||
|
||||
<artifact:dependencies pathId="classpath">
|
||||
<dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.5.0-m2"/>
|
||||
<dependency groupId="log4j" artifactId="log4j" version="1.2.13"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build" depends="init">
|
||||
<mkdir dir="${bin.dir}"/>
|
||||
<javac srcdir="${src.dir}" destdir="${bin.dir}">
|
||||
<classpath refid="classpath"/>
|
||||
</javac>
|
||||
<copy todir="${bin.dir}">
|
||||
<fileset dir="${src.dir}">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="contacts"/>
|
||||
|
||||
<target name="contacts" depends="build">
|
||||
<java classname="org.springframework.ws.samples.pox.client.sws.ContactsClient" fork="true" failonerror="true">
|
||||
<classpath refid="classpath"/>
|
||||
<classpath location="${bin.dir}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
7
samples/pox/client/spring-ws/src/log4j.properties
Normal file
7
samples/pox/client/spring-ws/src/log4j.properties
Normal file
@@ -0,0 +1,7 @@
|
||||
log4j.rootLogger=WARN, stdout
|
||||
log4j.logger.org.springframework.ws=DEBUG
|
||||
log4j.logger.org.springframework.xml=DEBUG
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - %m%n
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.pox.client.sws;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
|
||||
import org.springframework.xml.transform.ResourceSource;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.xpath.XPathExpression;
|
||||
|
||||
public class ContactsClient extends WebServiceGatewaySupport {
|
||||
|
||||
private Resource request;
|
||||
|
||||
private XPathExpression expression;
|
||||
|
||||
public ContactsClient(WebServiceMessageFactory messageFactory) {
|
||||
super(messageFactory);
|
||||
}
|
||||
|
||||
public void setRequest(Resource request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public void setExpression(XPathExpression expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public void contacts() throws IOException {
|
||||
Source requestSource = new ResourceSource(request);
|
||||
DOMResult result = new DOMResult();
|
||||
getWebServiceTemplate().sendSourceAndReceiveToResult(requestSource, result);
|
||||
int contactCount = (int) expression.evaluateAsNumber(result.getNode());
|
||||
System.out.println("contactCount = " + contactCount);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ApplicationContext applicationContext =
|
||||
new ClassPathXmlApplicationContext("applicationContext.xml", ContactsClient.class);
|
||||
ContactsClient contactsClient = (ContactsClient) applicationContext.getBean("contactsClient");
|
||||
contactsClient.contacts();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="contactsClient" class="org.springframework.ws.samples.pox.client.sws.ContactsClient">
|
||||
<constructor-arg ref="messageFactory"/>
|
||||
<property name="defaultUri" value="http://localhost:8080/pox/"/>
|
||||
<property name="request" value="classpath:org/springframework/ws/samples/pox/client/sws/contactsRequest.xml"/>
|
||||
<property name="expression" ref="expression"/>
|
||||
</bean>
|
||||
|
||||
<bean id="messageFactory" class="org.springframework.ws.pox.dom.DomPoxMessageFactory"/>
|
||||
|
||||
<bean id="expression" class="org.springframework.xml.xpath.XPathExpressionFactoryBean">
|
||||
<property name="namespaces">
|
||||
<props>
|
||||
<prop key="tns">http://www.springframework.org/spring-ws/samples/pox</prop>
|
||||
</props>
|
||||
</property>
|
||||
<property name="expression" value="/tns:ContactCount/text()"/>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Contacts xmlns="http://www.springframework.org/spring-ws/samples/pox">
|
||||
<Contact>
|
||||
<Name>John Doe</Name>
|
||||
<Phone>626-555-3456</Phone>
|
||||
</Contact>
|
||||
<Contact>
|
||||
<Name>Jane Doe</Name>
|
||||
<Phone>626-555-6543</Phone>
|
||||
</Contact>
|
||||
</Contacts>
|
||||
Reference in New Issue
Block a user