Prolog - Creating a list - list

Need a hand here creating a list. I need to return all possible combinations of prerequisites of courses, including the prerequisites of prerequisites.
Here are some rules and facts that I need to use, (Some provided, some I've created).
prereqFor(engg233, []).
prereqFor(encm339, [engg233]).
prereqFor(cpsc217, []).
prereqFor(cpsc219, [cpsc217]).
prereqFor(cpsc231, []).
prereqFor(cpsc233, [cpsc231]).
prereqFor(math271, [X]) :-
member(X, [math211, math213]).
prereqFor(math273, []).
prereqFor(cpsc319, [C]) :-
member(C, [cpsc219, cpsc233, cpsc235, encm339]).
prereqFor(cpsc331, [M, C]) :-
member(M, [math271, math273]),
member(C, [cpsc219, cpsc233, cpsc235, encm339]).
prereqFor(cpsc335, [C]) :-
member(C, [cpsc319, cpsc331]).
Now what I'm trying to do to accomplish this is two functions, one of which is a helper... And I can't seem to populate a list by using [H|T] or append... My current attempt:
allPrereqFor(Course, Prerequisites) :-
prereqFor(Course, Prerequisites),
creatingList(Course, Prerequisites, []).
creatingList(Course, Prerequisites, OnGoingList) :-
append(Course, Prerequisites, myList).
I also tried something like:
allPrereqFor(Course, Prerequisites) :-
prereqFor(Course, Prerequisites),
creatingList(Prerequisites, []).
creatingList(Addition, OnGoingList) :-
[Addition | OnGoingList].
I can't even get the most simple output before I even attempt a recursive case.
I have not listed every prereqFor function, but an example output would be:
| ?- allPrereqFor(cpsc331, X).
X = [cpsc217,cpsc219,math211,math271] ? ;
X = [cpsc231,cpsc233,math211,math271] ? ;
X = [consent235,cpsc235,math211,math271] ? ;
X = [encm339,engg233,math211,math271] ? ;
Another attempt at a solution...
allPrereqFor(Course,[],Result) :- append([Course],[],Result).
allPrereqFor(Course, X,Result) :- prereqFor(Course, Y),
Y=[H|T],
allPrereqFor(H,X,Result).
The trace:
| ?- allPrereqFor(cpsc331,X).
1 1 Call: allPrereqFor(cpsc331,_23) ?
1 1 Exit: allPrereqFor(cpsc331,[]) ?
X = [] ? ;
1 1 Redo: allPrereqFor(cpsc331,[]) ?
2 2 Call: prereqFor(cpsc331,_92) ?
3 3 Call: member(_78,[math271,math273]) ?
3 3 Exit: member(math271,[math271,math273]) ?
4 3 Call: member(_80,[cpsc219,cpsc233,cpsc235,encm339]) ?
4 3 Exit: member(cpsc219,[cpsc219,cpsc233,cpsc235,encm339]) ?
2 2 Exit: prereqFor(cpsc331,[math271,cpsc219]) ?
5 2 Call: allPrereqFor(math271,_23) ?
5 2 Exit: allPrereqFor(math271,[]) ?
1 1 Exit: allPrereqFor(cpsc331,[]) ?
X = [] ? ;
1 1 Redo: allPrereqFor(cpsc331,[]) ?
5 2 Redo: allPrereqFor(math271,[]) ?
When I trace I can see that it's recursively hitting all the right courses, but it just keeps outputting:
X = [] ?;

If I understand your question correctly then:
You are looking to build a list of combinations based on and and or predicates.
For example
to take cpsc219 you would need to take
cpsc217 and cpsc219
to take math271 you would need to take
math211 and math271 or
math213 and math271
In the link the example used a build of materials for a bike and build of materials for practical questions is similar to your prerequisites.
This answer will be using DCG because you are constructing list and with Prolog when working mostly with list DCG is preferred.
For the bike example the DCG rules only showed and DCG rules and after seeing your answer to my question in the comment you also need or DCG rules but those were not given in the bike example.
So just to review:
In Prolog and is done with , (,/2) and or which can be done with ; (;/2) but is more commonly done with multiple DCG rules. Note that , and ; as mentioned here are not list operators but operators working on goals.
An example of the bike and DCG rule for drivechain.
drivechain --> crank, pedal, pedal, chain.
Now the missing example of the or DCG rule implemented using multiple DCG rules
tire --> [dunlop].
tire --> [goodyear].
tire --> [yomoto].
or implemented using ;
tire -->
[dunlop]; [goodyear]; [yomoto].
A working example of the and DCG rule:
?- drivechain(X,[]).
X = [crank, pedal, pedal, chain] ;
false.
A working example of the or DCG rule:
?- tire(X,[]).
X = [dunlop] ;
X = [goodyear] ;
X = [yomoto] ;
false.
So for your problem with math271 needing math211 or math213 the DCG rules would be:
math211 --> [math211].
math213 --> [math213].
math271 --> math211.
math271 --> math213.
?- math271(X,[]).
X = [math211] ;
X = [math213].
Since you noted that this is an assignment in the original post I will take that to mean homework so I won't give a specific answer to your question but show you something similar using the bike example.
bike --> frame, drivechain, wheel, wheel.
wheel --> spokes, rim, hub, tire.
tire --> [dunlop].
tire --> [goodyear].
tire --> [yomoto].
drivechain --> crank, pedal, pedal, chain.
spokes --> [spokes].
crank --> [crank].
pedal --> [pedal].
chain --> [chain].
rim --> [rim].
hub --> [hub].
frame --> [frame].
?- bike(X,[]).
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear] ;
X = [frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto].
Notice that even though a tire is composed of three brands, there are 9 answers because there are two wheels each with a tire and each tire can be one of three brands thus 3 * 3 is 9.
SWI-Prolog specific:
Since some of these answers will be long and truncated with ... see this answer for help to see the entire answer without the .... In other words append ;false to the query and press w after the first answer, then press the space bar for more answers.
Since DCG is like syntactic sugar, to see the de-sugared DCG rules ( --> ) as predicates ( :- ) use listing/1, e.g.
?- listing(wheel).
wheel(A, E) :-
spokes(A, B),
rim(B, C),
hub(C, D),
tire(D, E).
true.
As I noted in the comments, I see that #false is probably going to answer this. I learn from him so I fully expect his answer to be better than mine, but I am posting my answer because if anyone sees a problem with my answer and points it out then I will learn also.
===================================
A more elaborate bike example that can make a bicycle or a tricycle.
bike --> type.
type --> bicycle.
type --> tricycle.
bicycle --> bicycle_frame, bicycle_drivechain, wheel, wheel.
tricycle --> tricycle_frame, tricycle_drive, wheel, wheel, wheel.
wheel --> spokes, rim, hub, tire.
bicycle_drivechain --> crank, pedal, pedal, chain.
tricycle_drive --> crank, pedal, pedal.
bicycle_frame --> [bicycle_frame].
tricycle_frame --> [tricycle_frame].
tire --> [dunlop].
tire --> [goodyear].
tire --> [yomoto].
spokes --> [spokes].
crank --> [crank].
pedal --> [pedal].
chain --> [chain].
rim --> [rim].
hub --> [hub].
?- bike(X,[]);false.
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear] ;
X = [bicycle_frame, crank, pedal, pedal, chain, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear, spokes, rim, hub, yomoto] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto, spokes, rim, hub, dunlop] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto, spokes, rim, hub, goodyear] ;
X = [tricycle_frame, crank, pedal, pedal, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto, spokes, rim, hub, yomoto] ;
false.

Finding the pre-requirements of pre-requirements can be done recursively. Well, you should make use of findall/3 and also flatten/2 which are defined in prolog library.
pre(X,Y):-
preRequirement(X,Y).
preRequirement(X,[(X-List)|Y]):-
findall(Z,prereqFor(X,Z),Res),
flatten(Res,List),
findPreOfPre(List,Y).
findPreOfPre([],[]).
findPreOfPre([H|T],[(H-L)|Result]):-
findall(P,prereqFor(H,P),N),
flatten(N,L),
findPreOfPre(T,Result).

Related

customize the fields returning from web service using ssrs xml query designer

i have a web service that returns data but i cannot find a way how to choose the fields that returns from the web service.
i have param-in that i send to the web service and i'm getting fields parameters as param-out.
this is how i'm parsing it:
<Query>
<Method Name="methodname" Namespace="namespacename">
<Paramenters>
<Parameter Name="param-in-name-1">
<DefaultValue>0</DefaultValue>
</Parameter>
<Parameter Name="param-in-name-2">
<DefaultValue>0</DefaultValue>
</Parameter>
</Parameters>
</Method>
<ElementPath IgnoreNamespace="true">
*
</ElementPath>
</Query>
this parsing above brings all fields but i need to take specific fields.
i tried to add this below to the elementpath but it didnt work:
/elementname1{}/elementname2{}/fieldname1
I realized that its really depend on the web service schema
for example,
this schema that i made more complex by adding nested parameters:
<wsdl:types>
<s:schema targetNamespace="VS13" elementFormDefault="qualified">
<s:element name="datatable">
<s:complexType>
<s:sequence>
<s:element name="prmin" type="tns:paramin" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="paramin">
<s:sequence>
<s:element name="name" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="age" type="s:int" maxOccurs="1" minOccurs="1"/>
<s:element name="height" type="s:int" maxOccurs="1" minOccurs="1"/>
</s:sequence>
</s:complexType>
<s:element name="datatableResponse">
<s:complexType>
<s:sequence>
<s:element name="datatableResult" type="tns:data" maxOccurs="1" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="data">
<s:sequence>
<s:element name="name" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="age" type="s:int" maxOccurs="1" minOccurs="1"/>
<s:element name="ltr" type="tns:ArrayOfLetters" maxOccurs="1" minOccurs="0"/>
<s:element name="height" type="s:int" maxOccurs="1" minOccurs="1"/>
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfLetters">
<s:sequence>
<s:element name="letters" type="tns:letters" maxOccurs="unbounded" minOccurs="0"/>
</s:sequence>
</s:complexType>
<s:complexType name="letters">
<s:sequence>
<s:element name="letter" type="s:string" maxOccurs="1" minOccurs="0"/>
<s:element name="count" type="s:int" maxOccurs="1" minOccurs="1"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
i made it more complicated by sending parameters from the second layer(parameters inside a class/element):
<Query>
<Method Name="datatable" Namespace="VS13" >
<Parameters>
<Parameter Name="prmin" Type="xml">
<DefaultValue>
<name>stiv</name>
<age>30</age>
<height>180</height>
</DefaultValue>
</Parameter>
</Parameters>
</Method>
there are 2 ways for me to implement the data retrieved from the xmldp query
1.second layer without the array data field:
<ElementPath IgnoreNamespaces="True">
datatableResponse/datatableResult
</ElementPath>
2.second layer only the array data field:
<ElementPath IgnoreNamespaces="True">
datatableResponse/datatableResult{}/ltr/letters{letter,count}
</ElementPath>

generating java artifacts for jax-ws application from remote wsdl

how to generate java artifacts (web service client)for jax-ws application from remote wsdl.
i tried below option but no luck. is their any other way to create it.
wsimport -d d:\test\ -s d:\cool wsdlurl(which is remote url)(eg.. http://servername/service.asmx?WSDL)
The above command ran in windows command prompt got below error.
[ERROR] Property "Any" is already defined. Use <jaxb:property> to resolve this conflict.
line 37 of http://xxx.xxxindia.com/service.asmx?WSDL
Any help would be appreciated. Thanks
Adding piece of WSDL for reference. Im getting error at "Any" attribute point
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://well.service.com/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://well.service.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://well.service.com/">
<s:element name="WhoAmI">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AccountId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="WhoAmIResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="WhoAmIResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SourceCity_InTravelTypeID">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="TravelTypeID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="AccountId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SourceCity_InTravelTypeIDResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SourceCity_InTravelTypeIDResult">
<s:complexType>
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax" />
<s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DestinationCity_InTravelTypeID">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="TravelTypeID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="StateID" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="AccountId" type="s:int" />
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DestinationCity_InTravelTypeIDResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="DestinationCity_InTravelTypeIDResult">
<s:complexType>
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax" />
<s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
Well, I can suggest a few things. First, what is "wsimpot"? Did you mean "wsimport"? And since you are on Windows, do you mean "wsimport.exe"?
Also, do you need to do anything to protect the url from interpretation by the shell? On OS X, we have to put single-quote characters around the url so that it gets past into the executable without being changed. Do you need to use single-quotes or double-quotes or something else?

gSOAP does not return information from web service, but it returns only schema

I am trying to retrieve project information from Microsoft Project Server Project web service.
I use gSOAP to implement the client. Here is how my code looks like:
if ( project.ReadProjectStatus(&read_project_status_message, &read_project_status_response) == SOAP_OK )
{
ofstream project_info("C:\\PROJECTINFO.XML");
project_info << read_project_status_response.ReadProjectStatusResult->__any;
}
Although the response from project server looks like:
<soap:Envelope ...>
<soap:Body ...>
<ReadProjectStatusResponse ...>
<ReadProjectStatusResult>
<xs:schema ...>
...
</xs:schema ...>
<diffgr:diffgram ...>
<ProjectDataSet ...>
....
</ProjectDataSet>
</diffgr:diffgram>
</ReadProjectStatusResult>
</ReadProjectStatusResponse>
</soap:Body>
</soap:Envelope>
when I open the file PROJECTINFO.XML (in which read_project_status_response.ReadProjectStatusResult->__any is written), I can see only the
<xs:schema ...>
...
</xs:schema>
part. Nothing about the project information.
Anyone knows why this happens and how I can retrieve project status info using gsoap?
Thanks in advance.
Too little too late, but here goes...
the wsdl provided by the project server is incomplete. It looks like this.
<s:element name="ReadProjectStatusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ReadProjectStatusResult">
<s:complexType>
<s:sequence>
<s:any namespace="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>
Change it to the following (note the extra s:element before s:any) and recompile using gsoap. Now gsoap will create 2 member variables (xsd__schema and __any). xsd__schema will contain the schema and __any will carry the right data.
<s:element name="ReadProjectStatusResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ReadProjectStatusResult">
<s:complexType>
<s:sequence>
<s:element ref="s:schema"/>
<s:any namespace="http://schemas.microsoft.com/office/project/server/webservices/ProjectDataSet/" />
</s:sequence>
</s:complexType>
</s:element>
</s:sequence>
</s:complexType>
</s:element>

What is the best way to develop an asp.net Webservice which will have methods that return list, individual objects or other complex datatypes

We are using .Net 2.0 to create webservices. We would like to design webservices in ASP.Net 2.0.
Currently the webservices we have return either a single parameter like
<s:element name="ChangePassword">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="currentPassword" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="newPassword" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ChangePasswordResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ChangePasswordResult" type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
We have also designed webservices that return a model like
<s:element name="GetCreditBalance">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetCreditBalanceResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetCreditBalanceResult" type="tns:UserCreditsModel" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="UserCreditsModel">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="UserId" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="CreditBalance" type="s:decimal" />
<s:element minOccurs="1" maxOccurs="1" name="ValidityDate" type="s:dateTime" />
</s:sequence>
</s:complexType>
We have also designed webservices that return a list of models like
<s:element name="GetHistory">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetHistoryResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetHistoryResult" type="tns:ArrayOfSMSCreditHistoryModel" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfSMSCreditHistoryModel">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="SMSCreditHistoryModel" nillable="true" type="tns:SMSCreditHistoryModel" />
</s:sequence>
</s:complexType>
<s:complexType name="SMSCreditHistoryModel">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="CreditHistoryId" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="UserId" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="PaymentDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="PaymentRefNo" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="TotalAmount" type="s:decimal" />
<s:element minOccurs="1" maxOccurs="1" name="CreditsEarned" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="ValidityDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="Mode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Status" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ChequeNO" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="ChequeDate" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="ChequeBankName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Remarks" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ValidityDateTime" type="s:string" />
</s:sequence>
</s:complexType>
The current approach is that if while any operation failure like authentication failure, we throw an exception from the webservice.
we would like to know which is the best approach to design a webservice so it can be consumed across various platforms without having technology issues.
Would use of json help. Would returning a pure XML will help.
In general, you should throw a SoapException from an ASMX web service to indicate a failure. This will return a SOAP Fault message back to the client.
However, ASMX web services do not have proper support for SOAP Faults. The generated WSDL will not indicate to your clients that your operations can return faults. This will prevent some clients from properly processing those faults.
So, you should really move up to WCF, which solves this problem. Your alternatives, if you must continue using .NET 2.0, are to not use SoapException, or to create your own WSDL, which should properly describe the faults returned from your operations.

How can I add SOAP Headers to a WSDL generated Borland C++ Builder 6 application

Using a WSDL that requires a SOAP HEADER for Authentication (fragment below) code that gets generated when creating a web service client via the "WSDL Importer" has no concept of the Authentication Headers and there are no examples in BCB6 C++ Examples/WebServices directories that show how, and nothing on Web that I can find.
Anyone with BCB6 C++ (not Delphi) have an example of adding SOAP Headers to a TRemotable subclass?
<s:element name="AuthenticationHeader" type="tns:AuthenticationHeader"/>
<s:complexType name="AuthenticationHeader">
<s:complexContent mixed="false">
<s:extension base="tns:UserAuthHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Function" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="TimeOutMilliSec" type="s:int"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="UserAuthHeader">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>