Я должен вскочить в Проект веб-сервиса Spring, в котором я потребовал для реализации Клиента веб-сервиса Spring Только..
Так, я уже довел Клиентский Справочный документ Spring до конца.
Так, я получил идею необходимых классов для реализации Клиента.
Но моя проблема похожа, я сделал некоторый поиск с помощью Google, но не получил надлежащего примера обоих Клиентов и серверов, от которых я могу реализовать один образец для своего клиента.
Так, если кто-либо дает мне некоторую ссылку или учебное руководство для надлежащего примера, из которого я могу узнать, что моя клиентская реализация значительно ценилась бы.
Заранее спасибо...
В моем предыдущем проекте я реализовал клиент веб-службы с помощью Spring 2.5.6, maven2, xmlbeans .
Я вставляю сюда несколько кодов и надеюсь, что они вам пригодятся.
xmlbeans maven plugin conf: (в pom.xml)
<build>
<finalName>projectname</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>target/generated-classes/xmlbeans
</directory>
</resource>
</resources>
<!-- xmlbeans maven plugin for the client side -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<schemaDirectory>src/main/resources/</schemaDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin
</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source> target/generated-sources/xmlbeans</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Итак, из приведенного выше conf вам нужно поместить файл схемы (автономный или в ваш файл WSDL, вам нужно извлечь их и сохранить как файл схемы .) в src / main / resources. когда вы создаете проект с помощью maven, pojos будет генерироваться xmlbeans. Сгенерированные исходные коды будут в разделе target / generated-sources / xmlbeans.
затем мы подошли к весенней конф. Я просто поместил здесь релевантный контекст WS:
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
<property name="payloadCaching" value="true"/>
</bean>
<bean id="abstractClient" abstract="true">
<constructor-arg ref="messageFactory"/>
</bean>
<bean id="marshaller" class="org.springframework.oxm.xmlbeans.XmlBeansMarshaller"/>
<bean id="myWebServiceClient" parent="abstractClient" class="class.path.MyWsClient">
<property name="defaultUri" value="http://your.webservice.url"/>
<property name="marshaller" ref="marshaller"/>
<property name="unmarshaller" ref="marshaller"/>
</bean>
наконец, взгляните на java-класс ws-client
public class MyWsClient extends WebServiceGatewaySupport {
//if you need some Dao, Services, just @Autowired here.
public MyWsClient(WebServiceMessageFactory messageFactory) {
super(messageFactory);
}
// here is the operation defined in your wsdl
public Object someOperation(Object parameter){
//instantiate the xmlbeans generated class, infact, the instance would be the document (marshaled) you are gonna send to the WS
SomePojo requestDoc = SomePojo.Factory.newInstance(); // the factory and other methods are prepared by xmlbeans
ResponsePojo responseDoc = (ResponsePojo)getWebServiceTemplate().marshalSendAndReceive(requestDoc); // here invoking the WS
//then you can get the returned object from the responseDoc.
}
}
Я надеюсь, что примеры кодов будут вам полезны.