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?
Related
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>
I am trying to consume .asmx webservice in coldfusion. I can view the WSDL but when trying to access methods it gives me the error:
Webservice Operation ... with parameters ... cannot be found
I have tried to add refreshwsdl = true as stated in other similar stackoverflow questions with no luck.
What am I missing?
<cfinvoke webservice = "urlhere.asmx?wsdl"
method="LoginRequest"
ReturnVariable ="result"
refreshwsdl="true" >
<cfinvokeargument name="oid" value="a">
<cfinvokeargument name="username" value="b">
<cfinvokeargument name="password" value="c">
</cfinvoke>
Here is that part of the WSDL:
<s:schema elementFormDefault="qualified" targetNamespace="http://blahblah">
<s:element name="loginRequest" type="s0:LoginRequest" />
<s:complexType name="LoginRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="oid" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="username" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string" />
</s:sequence>
Any ideas ?
Thanks!
You can try with the method described in the below link.
http://www.mindfiresolutions.com/ColdfusionMaking-a-call-to-a-Web-Service-with-complex-object-as-input-parameter-1228.php
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>
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.
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>