wsademo.h
来自「一款开源的soap库」· C头文件 代码 · 共 157 行
H
157 行
/*wsademo.hWS-Addressing demo service. See comments below.gSOAP XML Web services toolsCopyright (C) 2000-2006, Robert van Engelen, Genivia Inc., All Rights Reserved.This part of the software is released under one of the following licenses:GPL, the gSOAP public license, or Genivia's license for commercial use.--------------------------------------------------------------------------------gSOAP public license.The contents of this file are subject to the gSOAP Public License Version 1.3(the "License"); you may not use this file except in compliance with theLicense. You may obtain a copy of the License athttp://www.cs.fsu.edu/~engelen/soaplicense.htmlSoftware distributed under the License is distributed on an "AS IS" basis,WITHOUT WARRANTY OF ANY KIND, either express or implied. See the Licensefor the specific language governing rights and limitations under the License.The Initial Developer of the Original Code is Robert A. van Engelen.Copyright (C) 2000-2006, Robert van Engelen, Genivia Inc., All Rights Reserved.--------------------------------------------------------------------------------GPL license.This program is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the Free SoftwareFoundation; either version 2 of the License, or (at your option) any laterversion.This program is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more details.You should have received a copy of the GNU General Public License along withthis program; if not, write to the Free Software Foundation, Inc., 59 TemplePlace, Suite 330, Boston, MA 02111-1307 USAAuthor contact information:engelen@genivia.com / engelen@acm.org--------------------------------------------------------------------------------A commercial use license is available from Genivia, Inc., contact@genivia.com--------------------------------------------------------------------------------This application demonstrates server-side and client-side logic for servicesbased on WS-Addressing. At the server side, WS-Addressing enablesforwarding/relaying of service responses and faults to other services. At theclient side, a relayed response or fault will not be received and an HTTPACCEPTED (code 202) is delivered instead, assuming that the relay wassuccessful.This header file illustrates two gSOAP soapcpp2 tooling tricks to enableservices to accept SOAP Fault messages and to create a one-way serviceoperation to handle responses. Usage: After compilation, start the main server at port 11001: > ./wsademo 11001 In a new window, start a return service at port 11002: > ./wsademo 11002 This service handles response messages from the main service. In a new window, start a fault service at port 11003: > ./wsademo 11003 This service handles faults from the main service. In a new window, run the client: > ./wsademo hello This example shows the server returning "hello" to the client. > ./wsademo fault This example shows the server returning a SOAP fault to the client. > ./wsademo hello r This example shows the server returning "hello" to the return service. > ./wsademo error e This example shows the server returing a wsa fault to the fault service. > ./wsademo fault e This example shows the server returing a SOAP fault to fault service. Note: when the response service is down, the response cannot be relayed and the client (or fault service) will be informed about the failure.*/#import "soap12.h"#import "wsa.h"//gsoap ns service name: wsademo demonstrates WS-Addressing capabilities//gsoap ns service port: http://localhost:11001//gsoap ns service type: wsademoPort//gsoap ns service namespace: urn:wsademostruct SOAP_ENV__Header{ _wsa__MessageID wsa__MessageID 0; _wsa__RelatesTo *wsa__RelatesTo 0; _wsa__From *wsa__From 0; mustUnderstand _wsa__ReplyTo *wsa__ReplyTo 0; mustUnderstand _wsa__FaultTo *wsa__FaultTo 0; mustUnderstand _wsa__To wsa__To 0; mustUnderstand _wsa__Action wsa__Action 0;};/* TRICK 1: generate SOAP-ENV:Fault struct via a one-way service operation. * This allows us to implement a one-way service operation that accepts Faults. * Because a service operation input parameters has a corresponding struct, we * automatically generate the (original) SOAP_ENV__Fault struct on the fly! * Note: it is important to associate the wsa fault action with this operation * as defined below. */ //gsoap SOAP_ENV service method-action: Fault http://schemas.xmlsoap.org/ws/2004/08/addressing/faultint SOAP_ENV__Fault( _QName faultcode, // SOAP 1.1 char *faultstring, // SOAP 1.1 char *faultactor, // SOAP 1.1 struct SOAP_ENV__Detail *detail, // SOAP 1.1 struct SOAP_ENV__Code *SOAP_ENV__Code, // SOAP 1.2 struct SOAP_ENV__Reason *SOAP_ENV__Reason, // SOAP 1.2 char *SOAP_ENV__Node, // SOAP 1.2 char *SOAP_ENV__Role, // SOAP 1.2 struct SOAP_ENV__Detail *SOAP_ENV__Detail, // SOAP 1.2 void);/* TRICK 2: generate response struct via a one-way service response operation. * Because the service operation has a corresponding struct, we can use that * struct as a response parameter for the second two-way service operation. *///gsoap ns service method-header-part: wsademoResult wsa__MessageID//gsoap ns service method-header-part: wsademoResult wsa__RelatesTo//gsoap ns service method-header-part: wsademoResult wsa__From//gsoap ns service method-header-part: wsademoResult wsa__ReplyTo//gsoap ns service method-header-part: wsademoResult wsa__FaultTo//gsoap ns service method-header-part: wsademoResult wsa__To//gsoap ns service method-header-part: wsademoResult wsa__Action//gsoap ns service method-action: wsademoResult urn:wsademo/wsademoPort/wsademoResult//gsoap ns service method-documentation: wsademoResult accepts a string value from a relayed responseint ns__wsademoResult(char *out, void);//gsoap ns service method-header-part: wsademo wsa__MessageID//gsoap ns service method-header-part: wsademo wsa__RelatesTo//gsoap ns service method-header-part: wsademo wsa__From//gsoap ns service method-header-part: wsademo wsa__ReplyTo//gsoap ns service method-header-part: wsademo wsa__FaultTo//gsoap ns service method-header-part: wsademo wsa__To//gsoap ns service method-header-part: wsademo wsa__Action//gsoap ns service method-action: wsademo urn:wsademo/wsademoPort/wsademo//gsoap ns service method-documentation: wsademo echos a string value and relays the response to the wsa replyTo address (if present)int ns__wsademo(char *in, struct ns__wsademoResult *result);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?