I created a simple web service and a WSDL for it. In my WSDL I have five parameters for my SOAP response.
<message name="EmailStatusResponse">
<part name='id' type='xsd:integer'/>
<part name='name' type='xsd:string'/>
<part name='message' type='xsd:string'/>
<part name='createdDate' type='xsd:date'/>
<part name='approver' type='xsd:string'/>
</message>
I want to create a client using my WSDL with eclipse and Axis2. The format of the createdDate which I receive through SOAP response is DD/MM/YYYY. When I run the client it throws an AxisFault saying that date format of createdDate is incorrect.
I know this would work if I change the date format sent in SOAP response to DD/MM/YYYY or change the type of the createdDate parameter in WSDL to xsd:string.
My question is, is there a way to specify the date pattern in WSDL?
For an example something like this:
<part name='createdDate' type='xsd:date' pattern="DD/MM/YYYY"/> Thanks.
You can declare it a string and then restrict the pattern of the string like so:
<xs:simpleType name="createdDate">
<xs:restriction base="xs:string">
<xs:pattern value="(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/\d{4}"/>
</xs:restriction>
</xs:simpleType>
This will get you the right format but you could have problems with the SOAP type being a string.
You can use schema to have your preferred pattern?
Related
I have problem with geting full response from SOAP WS in Progress OpenEdge.
"bprowsdldoc" app generated full call and output structure to DATASET, but in DATASET I have only last element of "document" type.
Response looks like this:
<GetDocumentsResponse>
<documentsCount>3</documentsCount>
<document>
<content filename="file1.xml" mime="application/xml"> [base64] </content>
</document>
<document>
<content filename="file2.xml" mime="application/xml"> [base64] </content>
</document>
<document>
<content filename="file3.xml" mime="application/xml"> [base64] </content>
</document>
<documentsInfo>All done.</documentsInfo>
</GetDocumentsResponse>
My goal is to get all "document" elements in output DATASET (count of 3 is only a sample) or get full response XML as LONGCHAR.
Any help will be appreciated.
EDIT:
Web service is internal in my company and calling it requiers VPN connection, so I can't give You link.
But bprowsdldoc generated a code like this for method "GetDocuments":
DEFINE VARIABLE dateStart AS DATE NO-UNDO.
DEFINE VARIABLE dateEnd AS DATE NO-UNDO.
DEFINE VARIABLE documentsCount AS INT64 NO-UNDO.
DEFINE TEMP-TABLE document NO-UNDO
FIELD docId AS CHARACTER.
DEFINE TEMP-TABLE content NO-UNDO
FIELD filename AS CHARACTER
XML-NODE-TYPE "ATTRIBUTE"
FIELD mime AS CHARACTER
XML-NODE-TYPE "ATTRIBUTE"
FIELD content_Text AS RAW
XML-NODE-TYPE "TEXT"
FIELD document_id AS RECID
XML-NODE-TYPE "HIDDEN" .
DEFINE DATASET documentDset
XML-NODE-TYPE "HIDDEN"
FOR document, content
PARENT-ID-RELATION RELATION1 FOR document, content
PARENT-ID-FIELD document_id.
DEFINE VARIABLE documentsInfo AS CHARACTER NO-UNDO.
RUN GetDocuments IN hDocumentHandlingPort(INPUT dateStart, INPUT dateEnd, OUTPUT documentsCount, OUTPUT DATASET documentDset, OUTPUT documentsInfo).
After calling this method I get proper response for variables documentsCount and documentsInfo but in TEMP-TABLE content I got only one row with document element from response (there should be 3 for dates from 2017-03-16 to 2017-03-16 as ine example response on the top of my post).
Response in WSDL looks like this:
<xs:element name="GetDocumentsResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="documentsCount" type="xs:long"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="document" type="ns1:documentType"/>
<xs:element minOccurs="0" name="documentsInfo" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I think that problem may be related to maxOccurs attribute of element document - it's unbounded and maybe there should be some numeric value...
Can You help mi handle this problem?
Due to defect PSC00323593, described in knowledge base, this situation is a bug. But there is always light in the dark, so there is also workaround for it:
Use the WSDL Analyzer (bprowsdldoc) with -show100style parameter to
generate documentation. Using the older syntax works as desired,
returning all expected records.
In the scenario encountered, the alternate documentation uses type
LONGCHAR for parameters. It was then possible to combine code from
original documentation (specifically the TEMP-TABLE and DATASET
definitions) with the code from the -show100style documentation. The
READ-XML method was used to read the LONGCHAR output parameter into
the DATASET.
or
Add APPEND option to the DATASET parameter.
You can find full article here.
I have an xml schema from a third party web service provider.
<xsd:element name="Student">
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1"/>
<xs:element name="Address" type="xs:string" minOccurs="0"/>
<xs:element name="Gender" type="xs:string" minOccurs="1"/>
</xs:sequence>
</xsd:element>
I am going to consume the dataset returns from this web service in my C# code. Since Address has the minOccurs set to 0, it means the web service can either return value for Address or not returning Address. For example:
Scenario 1:
<Student>
<Name>Eddie</Name>
<Gender>Male</Gender>
</Student>
Scenario 2:
<Student>
<Name>Alice</Name>
<Address>White House</Address>
<Gender>Female</Gender>
</Student>
Scenario 3:
<Student>
<Name>Jenny</Name>
<Address></Address>
<Gender>Female</Gender>
</Student>
May I know how do I check, in my C# code whether the web service return Address.
For result set from Scenario 1, I would like to hide the contact Section from my form all together.
For result set from Scenario 2, I would like to display the contact Section on my form, and have the address display.
For result set from Scenario 3, I would like to display the contact Section on my form, but have the Address field in the contact section set to "Address not provided".
May I know could I achieve that?
I know we can check whether the elements hasvalue or isnull. But how do we check whether the result returned by the web service contains the element (Scenario 1)?
After some research and testing done, I think I can have something like this:
bool ShowContactFlag = false;
if (Dataset.Tables[0].Columns.Contains("Address"))
{
ShowContactFlag = true;
}
else
{
ShowContactFlag = false;
}
This is regarding xml transformation within BPEL.
In my bpel process, data is coming from two separate sources (partnerLinks).
Data from both sources is in the same xml format.
I need to combine the data from the two XML documents into one xml document and then pass it back to the ESB.
I was trying with bpel:doXslTransform()).
I am not sure how to pass the two responses from the partnerLinks to this function in a single call.
I tried concatenating the two responses into a string within a message type variable and then pass this to the bpel:doXslTransform(). Is this the right approach to merge the data?
Yes, you can do a bpel:doXslTransform here.
This involves receiving an XML document from one service, converting it to a different Schema to form a new request message, and sending the new request to another service. Such documentation conversion can be accomplished using XSLT via the bpel:doXslTransform function.
<variables>
<variable name="A" element="foo:AElement" />
<variable name="B" element="bar:BElement" />
</variables>
...
<sequence>
<invoke ... inputVariable="..." outputVariable="A" />
<assign>
<copy>
<from>
bpel:doXslTransform("urn:stylesheets:A2B.xsl", $A)
</from>
<to variable="B" />
</copy>
</assign>
<invoke ... inputVariable="B" ... />
</sequence>
Please refer http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.html for further information.
I'm new to web services world, and I've seen in different tutorials that some of them use xs:string for data type and some use xsd:string for messages in w3schools.com tut is as below:
<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>
And for example in Apress Beginning PHP and MySQL is as the following code:
<message name="getTermResponse">
<part name="value" type="xsd:string"/>
</message>
What is the differences between them? which one to use when?
xs:string is an example of a qualified name in XML. The xs part refers to a namespace declaration on the same element or a parent element. Most likely, there's an xmlns:xs=http://www.w3.org/2001/XMLSchema declaration.
xsd:string is exactly the same thing, assuming that the declaration is xmlns:xsd=http://www.w3.org/2001/XMLSchema. foo:string would also be the same, if the declaration were xmlns:foo=http://www.w3.org/2001/XMLSchema.
In other words, the prefix does not matter. It is an alias for the namespace. If the namespaces are the same, and the local names are the same, then the two qualified names are the same.
I am trying to forward ArrayList as the parameter from .Net environment to the webservice file generated by Axis2. But it's displaying the type as follows in the WSDL file
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="myMethod" nillable="true" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
Also, if I test the WSDL file using the soapPUI, it's displaying the following message in the Form "Type : [{http://www.w3.org/2001/XMLSchema}anyType] is not supported by the Form Editor"
And if I manually forward the details in the XML file then it's displaying the following error message : org.apache.axiom.om.impl.llom.OMTextImpl cannot be cast to java.lang.String
What am I supposed to do to fix this issue ?
You're not passing an array list but rather an array of objects, and I don't believe such an array is serializable:
Dim resultString As String = MyService.myMethod(myAL.toArray)
What type is the myMethod argument?