Updated C# sample
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
target:
|
||||
wsdl -namespace:Spring.Ws.Samples.Airline.Client.CSharp -out:src/AirlineService.cs ../../src/main/webapp/airline.wsdl
|
||||
mcs -out:bin/airline.exe -r:System.Web.Services src/main.cs src/AirlineService.cs
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
@echo off
|
||||
set WSE_PATH="C:\Program Files\Microsoft WSE\v2.0"
|
||||
%WSE_PATH%\Tools\Wsdl\WseWsdl2 ..\..\src\main\webapp\airline.wsdl src\AirlineService-wse.cs
|
||||
csc -nologo -out:bin\getmileage.exe -reference:%WSE_PATH%\Microsoft.Web.Services2.dll src\wse.cs src\AirlineService-wse.cs
|
||||
@@ -1,3 +0,0 @@
|
||||
set WSE_PATH="C:\Program Files\Microsoft WSE\v2.0"
|
||||
%WSE_PATH%\Tools\Wsdl\WseWsdl2 ..\..\src\main\webapp\airline.wsdl src\AirlineService-wse.cs
|
||||
csc -out:bin\airline-wse.exe -reference:%WSE_PATH%\Microsoft.Web.Services2.dll src\wse.cs src\AirlineService-wse.cs
|
||||
@@ -1,2 +0,0 @@
|
||||
wsdl -out:src\AirlineService.cs ..\..\src\webapp\airline.wsdl ..\..\src\webapp\airline.xsd
|
||||
csc -out:bin\airline.exe src\main.cs src\AirlineService.cse.csosoft WSE\v2.0\Microsoft.Web.Services2.dll" -define:WSE src\main.cs src\AirlineService.cs
|
||||
50
samples/airline/client/cs/build.xml
Normal file
50
samples/airline/client/cs/build.xml
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="spring-ws-airline-sample-saaj-client" default="build">
|
||||
|
||||
<property name="bin.dir" value="bin"/>
|
||||
<property name="src.dir" value="src"/>
|
||||
<property name="gen.dir" value="gen"/>
|
||||
<property name="wsdl" value="http://localhost:8080/airline/airline.wsdl"/>
|
||||
<property name="exe" value="bin/airline.exe"/>
|
||||
|
||||
<condition property="windows">
|
||||
<os family="windows"/>
|
||||
</condition>
|
||||
|
||||
<target name="generate" >
|
||||
<mkdir dir="${gen.dir}"/>
|
||||
|
||||
<wsdltodotnet url="${wsdl}" destfile="${gen.dir}/AirlineService.cs"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="build" depends="generate">
|
||||
<mkdir dir="${bin.dir}"/>
|
||||
<csc targettype="exe" destfile="${bin.dir}/airline.exe" references="System.Web.Services">
|
||||
<src dir="${src.dir}"/>
|
||||
<src dir="${gen.dir}"/>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin.dir}"/>
|
||||
<delete dir="${gen.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="run-windows" if="windows">
|
||||
<exec executable="${exe}"/>
|
||||
</target>
|
||||
|
||||
<target name="run-non-windows" unless="windows">
|
||||
<exec executable="mono">
|
||||
<arg path="${exe}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="build">
|
||||
<antcall target="run-windows"/>
|
||||
<antcall target="run-non-windows"/>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -1,20 +1,10 @@
|
||||
SPRING WEB SERVICES
|
||||
|
||||
This directory contains two C# clients for the Airline Web Service. One sample (airline.exe) uses non-secure
|
||||
functionality, and works under both .NET and Mono, while getmileage.exe only works under .NET because it relies on
|
||||
Microsoft's Web Services enhancements (WSE 2.0) to perform WS-Security.
|
||||
This directory contains a .NET client for the Airline Web Service.
|
||||
The client can be run from the provided ant file, by calling "ant run".
|
||||
|
||||
The C# client is executable: just run the executable file and (if the war file is deployed at the default
|
||||
http://localhost:8080/airline) the web service will be called, causing a flight reservations to be created.
|
||||
|
||||
If the web service is NOT running at the default URL, you can append the URL argument to the exectuable file
|
||||
(e.g. 'airline.exe http://localhost:8080/airline-webservice/Airline').
|
||||
|
||||
|
||||
C# Client Sample table of contents
|
||||
SAJA Client Sample table of contents
|
||||
---------------------------------------------------
|
||||
* bin - The executable files for the clients: airline.exe and getmileage.exe
|
||||
* src - The source files for the clients.
|
||||
* Makefile - Mono makefile.
|
||||
* build.bat - .NET build batch file for airline.exe
|
||||
* build-getmileage.bat - .NET build batch file for getmileage.exe
|
||||
* src - The source files for the client
|
||||
* build.xml - Ant build file with a 'build' and a 'run' target
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version: 1.1.4322.2032
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// InfoVersionComment, WseWsdl2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=26ba029e599ec4f8, RunTime Version: 1.1.4322.2032
|
||||
//
|
||||
using System;
|
||||
using System.Xml;
|
||||
using Microsoft.Web.Services2;
|
||||
using Microsoft.Web.Services2.Addressing;
|
||||
using Microsoft.Web.Services2.Messaging;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
|
||||
[SoapService("http://www.springframework.org/spring-ws/samples/airline/definitions")]
|
||||
public class AirlineService : SoapClient
|
||||
{
|
||||
public AirlineService() : base( new Uri("http://localhost:8080/airline/Airline") )
|
||||
{
|
||||
}
|
||||
|
||||
[SoapMethod("http://www.springframework.org/spring-ws/samples/airline/GetFlights")]
|
||||
public SoapEnvelope GetFlights( SoapEnvelope request )
|
||||
{
|
||||
return base.SendRequestResponse("GetFlights", request);
|
||||
}
|
||||
|
||||
public IAsyncResult BeginGetFlights( SoapEnvelope request, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return base.BeginSendRequestResponse("GetFlights", request, callback, asyncState);
|
||||
}
|
||||
|
||||
public SoapEnvelope EndGetFlights( System.IAsyncResult asyncResult )
|
||||
{
|
||||
return base.EndSendRequestResponse(asyncResult);
|
||||
}
|
||||
|
||||
[SoapMethod("http://www.springframework.org/spring-ws/samples/airline/BookFlight")]
|
||||
public SoapEnvelope BookFlight( SoapEnvelope request )
|
||||
{
|
||||
return base.SendRequestResponse("BookFlight", request);
|
||||
}
|
||||
|
||||
public IAsyncResult BeginBookFlight( SoapEnvelope request, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return base.BeginSendRequestResponse("BookFlight", request, callback, asyncState);
|
||||
}
|
||||
|
||||
public SoapEnvelope EndBookFlight( System.IAsyncResult asyncResult )
|
||||
{
|
||||
return base.EndSendRequestResponse(asyncResult);
|
||||
}
|
||||
|
||||
[SoapMethod("http://www.springframework.org/spring-ws/samples/airline/GetFrequentFlyerMileage")]
|
||||
public SoapEnvelope GetFrequentFlyerMileage( SoapEnvelope request )
|
||||
{
|
||||
return base.SendRequestResponse("GetFrequentFlyerMileage", request);
|
||||
}
|
||||
|
||||
public IAsyncResult BeginGetFrequentFlyerMileage( SoapEnvelope request, System.AsyncCallback callback, object asyncState)
|
||||
{
|
||||
return base.BeginSendRequestResponse("GetFrequentFlyerMileage", request, callback, asyncState);
|
||||
}
|
||||
|
||||
public SoapEnvelope EndGetFrequentFlyerMileage( System.IAsyncResult asyncResult )
|
||||
{
|
||||
return base.EndSendRequestResponse(asyncResult);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a tool.
|
||||
// Mono Runtime Version: 1.1.4322.2032
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// This source code was auto-generated by Mono Web Services Description Language Utility
|
||||
//
|
||||
namespace Spring.Ws.Samples.Airline.Client.CSharp {
|
||||
|
||||
|
||||
/// <remarks/>
|
||||
[System.Web.Services.WebServiceBinding(Name="AirlinePort", Namespace="http://www.springframework.org/spring-ws/samples/airline/definitions")]
|
||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
||||
public class AirlineService : System.Web.Services.Protocols.SoapHttpClientProtocol {
|
||||
|
||||
public AirlineService() {
|
||||
this.Url = "http://localhost:8080/airline/Airline";
|
||||
}
|
||||
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.springframework.org/spring-ws/samples/airline/GetFlights", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
|
||||
[return: System.Xml.Serialization.XmlArray(ElementName="GetFlightsResponse", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
[return: System.Xml.Serialization.XmlArrayItem(ElementName="flight", IsNullable=false)]
|
||||
public Flight[] GetFlights([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")] MessageGetFlightsRequest GetFlightsRequest) {
|
||||
object[] results = this.Invoke("GetFlights", new object[] {
|
||||
GetFlightsRequest});
|
||||
return ((Flight[])(results[0]));
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginGetFlights(MessageGetFlightsRequest GetFlightsRequest, System.AsyncCallback callback, object asyncState) {
|
||||
return this.BeginInvoke("GetFlights", new object[] {
|
||||
GetFlightsRequest}, callback, asyncState);
|
||||
}
|
||||
|
||||
public Flight[] EndGetFlights(System.IAsyncResult asyncResult) {
|
||||
object[] results = this.EndInvoke(asyncResult);
|
||||
return ((Flight[])(results[0]));
|
||||
}
|
||||
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.springframework.org/spring-ws/samples/airline/BookFlight", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
|
||||
[return: System.Xml.Serialization.XmlElementAttribute("BookFlightResponse", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public Ticket BookFlight([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")] MessageBookFlightRequest BookFlightRequest) {
|
||||
object[] results = this.Invoke("BookFlight", new object[] {
|
||||
BookFlightRequest});
|
||||
return ((Ticket)(results[0]));
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginBookFlight(MessageBookFlightRequest BookFlightRequest, System.AsyncCallback callback, object asyncState) {
|
||||
return this.BeginInvoke("BookFlight", new object[] {
|
||||
BookFlightRequest}, callback, asyncState);
|
||||
}
|
||||
|
||||
public Ticket EndBookFlight(System.IAsyncResult asyncResult) {
|
||||
object[] results = this.EndInvoke(asyncResult);
|
||||
return ((Ticket)(results[0]));
|
||||
}
|
||||
|
||||
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.springframework.org/spring-ws/samples/airline/GetFrequentFlyerMileage", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
|
||||
[return: System.Xml.Serialization.XmlElementAttribute("GetFrequentFlyerMileageResponse", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public int GetFrequentFlyerMileage([System.Xml.Serialization.XmlElementAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")] object GetFrequentFlyerMileageRequest) {
|
||||
object[] results = this.Invoke("GetFrequentFlyerMileage", new object[] {
|
||||
GetFrequentFlyerMileageRequest});
|
||||
return ((int)(results[0]));
|
||||
}
|
||||
|
||||
public System.IAsyncResult BeginGetFrequentFlyerMileage(object GetFrequentFlyerMileageRequest, System.AsyncCallback callback, object asyncState) {
|
||||
return this.BeginInvoke("GetFrequentFlyerMileage", new object[] {
|
||||
GetFrequentFlyerMileageRequest}, callback, asyncState);
|
||||
}
|
||||
|
||||
public int EndGetFrequentFlyerMileage(System.IAsyncResult asyncResult) {
|
||||
object[] results = this.EndInvoke(asyncResult);
|
||||
return ((int)(results[0]));
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
[System.Xml.Serialization.XmlRootAttribute("GetFlightsRequest", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class MessageGetFlightsRequest {
|
||||
|
||||
/// <remarks/>
|
||||
public string from;
|
||||
|
||||
/// <remarks/>
|
||||
public string to;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(DataType="date")]
|
||||
public System.DateTime departureDate;
|
||||
|
||||
/// <remarks/>
|
||||
public ServiceClass serviceClass;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlIgnore()]
|
||||
public bool serviceClassSpecified;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public enum ServiceClass {
|
||||
|
||||
/// <remarks/>
|
||||
economy,
|
||||
|
||||
/// <remarks/>
|
||||
business,
|
||||
|
||||
/// <remarks/>
|
||||
first,
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class Flight {
|
||||
|
||||
/// <remarks/>
|
||||
public string number;
|
||||
|
||||
/// <remarks/>
|
||||
public System.DateTime departureTime;
|
||||
|
||||
/// <remarks/>
|
||||
public Airport from;
|
||||
|
||||
/// <remarks/>
|
||||
public System.DateTime arrivalTime;
|
||||
|
||||
/// <remarks/>
|
||||
public Airport to;
|
||||
|
||||
/// <remarks/>
|
||||
public ServiceClass serviceClass;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class Airport {
|
||||
|
||||
/// <remarks/>
|
||||
public string code;
|
||||
|
||||
/// <remarks/>
|
||||
public string name;
|
||||
|
||||
/// <remarks/>
|
||||
public string city;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
[System.Xml.Serialization.XmlRootAttribute("BookFlightRequest", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class MessageBookFlightRequest {
|
||||
|
||||
/// <remarks/>
|
||||
public string flightNumber;
|
||||
|
||||
/// <remarks/>
|
||||
public System.DateTime departureTime;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlArrayItem(ElementName="passenger", Type=typeof(Name), IsNullable=false)]
|
||||
[System.Xml.Serialization.XmlArrayItem(ElementName="username", Type=typeof(string), IsNullable=false)]
|
||||
public object[] passengers;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class Name {
|
||||
|
||||
/// <remarks/>
|
||||
public string first;
|
||||
|
||||
/// <remarks/>
|
||||
public string last;
|
||||
}
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
[System.Xml.Serialization.XmlRootAttribute("BookFlightResponse", Namespace="http://www.springframework.org/spring-ws/samples/airline/schemas")]
|
||||
public class Ticket {
|
||||
|
||||
/// <remarks/>
|
||||
public long id;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlElementAttribute(DataType="date")]
|
||||
public System.DateTime issueDate;
|
||||
|
||||
/// <remarks/>
|
||||
[System.Xml.Serialization.XmlArrayItem(ElementName="passenger", IsNullable=false)]
|
||||
public Name[] passengers;
|
||||
|
||||
/// <remarks/>
|
||||
public Flight flight;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Services.Protocols;
|
||||
using System.Xml;
|
||||
using Microsoft.Web.Services2;
|
||||
using Microsoft.Web.Services2.Security;
|
||||
using Microsoft.Web.Services2.Security.Tokens;
|
||||
|
||||
namespace Spring.Ws.Samples.Airline.Client.CSharp {
|
||||
|
||||
public class Client {
|
||||
public static void Main(string[] args) {
|
||||
try {
|
||||
AirlineService service = new AirlineService();
|
||||
if (args.Length > 0) {
|
||||
service.Destination = new Uri(args[0]);
|
||||
}
|
||||
SoapEnvelope request = new SoapEnvelope();
|
||||
request.SetBodyObject(@"<GetFrequentFlyerMileage xmlns=""http://www.springframework.org/spring-ws/samples/airline/schemas""/>");
|
||||
UsernameToken userToken = new UsernameToken("john","changeme", PasswordOption.SendHashed);
|
||||
request.Context.Security.Tokens.Add(userToken);
|
||||
SoapEnvelope response = service.GetFrequentFlyerMileage(request);
|
||||
int miles = XmlConvert.ToInt32(response.Body.FirstChild.InnerText);
|
||||
Console.Out.WriteLine("'john' has {0} frequent flyer miles", miles);
|
||||
} catch (SoapException ex) {
|
||||
Console.Error.WriteLine("SOAP Fault Code {0}", ex.Code);
|
||||
Console.Error.WriteLine("SOAP Fault String: {0}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user