Problem consuming webservice in grails using ws-client? - asp.net

Property of webservice
<s:complexType name="Package_Attributes">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="ID" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="PackageID" type="s:int"/>
</s:sequence>
</s:complexType>
Grails code
def result = proxy.GetPackageAttributes()
render result.ID
render result.PACKAGEID
Error
i am able to get "ID"
but "PACKAGEID" is not working
i am able to consume this in Dot.Net platform, so there is no problem with webservice...

Related

Oozie global configurations

Based on oozie doc I understand that I can use the global element to avoid repeating, let's say, the job-tracker specification, for every action. Although, given the following simple workflow:
<workflow-app name="Test Hello World" xmlns="uri:oozie:workflow:0.4">
<global>
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
</global>
<start to="import"/>
<action name="import">
<shell xmlns="uri:oozie:shell-action:0.1">
<exec>hw.sh</exec>
<file>hw.sh#hw.sh</file>
</shell>
<ok to="end"/>
<error to="kill"/>
</action>
<kill name="kill">
<message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>
</workflow-app>
when running oozie validate on it I get:
Error: Invalid app definition, org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 19; cvc-complex-type.2.4.a: Invalid content was found starting with element 'exec'. One of '{"uri:oozie:shell-action:0.1":job-tracker}' is expected.
So basically, it still expects a job-tracker element in the action.
If you have any idea on this behavior, your answers will be much appreciated.
Thank you.
Here is the schema of oozie shell action version 0.1. You will notice that job-tracker and name-node tags require the minimum occurrence of 1 time. Same applies for the exec tag as well.
Source: Shell XML-Schema
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:shell="uri:oozie:shell-action:0.1" elementFormDefault="qualified"
targetNamespace="uri:oozie:shell-action:0.1">
<xs:element name="shell" type="shell:ACTION"/>
<xs:complexType name="ACTION">
<xs:sequence>
<xs:element name="job-tracker" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="name-node" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="prepare" type="shell:PREPARE" minOccurs="0" maxOccurs="1"/>
<xs:element name="job-xml" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="configuration" type="shell:CONFIGURATION" minOccurs="0" maxOccurs="1"/>
<xs:element name="exec" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="argument" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="env-var" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="file" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="archive" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="capture-output" type="shell:FLAG" minOccurs="0" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="FLAG"/>
<xs:complexType name="CONFIGURATION">
<xs:sequence>
<xs:element name="property" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="value" minOccurs="1" maxOccurs="1" type="xs:string"/>
<xs:element name="description" minOccurs="0" maxOccurs="1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="PREPARE">
<xs:sequence>
<xs:element name="delete" type="shell:DELETE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="mkdir" type="shell:MKDIR" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DELETE">
<xs:attribute name="path" type="xs:string" use="required"/>
</xs:complexType>
<xs:complexType name="MKDIR">
<xs:attribute name="path" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>

How to declare optional date field in XSD

I was using XSD to validate my incoming XML elements.
XSD File
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.rg/2001/XMLSchema"
xmlns:tns="http://xxxy/ervices/V0"
targetNamespace="http://xxxy/ervices/V" elementFormDefault="qualified"
attributeFormDefault="unqualified" >
<xs:complexType name="FailType">
<xs:sequence>
<xs:element name="ConDt" type="xs:date" minOccurs="0" maxOccurs="1" nillable="true"/>
<xs:element name="PreEn" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
My XML File
<Pat xmlns="http://xxxy/ervices/V">
<ConDt></ConDt>
</Pat>
I was getting element is invalid - The value '' is invalid according to its datatype 'http://org/2001/XMLSchema:date' - The string '' is not a valid Date value.
Specifying nillable="true" allows your instance to contain
<ConDt xsi:nil="true"></ConDt>
but it doesn't allow you to write
<ConDt></ConDt>
(Please don't ask me what they were thinking...)
If you want to allow
<ConDt></ConDt>
Then two possible approaches are
define it as a union type that allows either an xs:date or a
zero-length string, or
(my preferred approach) define it as a list type: a list of xs:date values with maxLength="1".
Thanks a lot Michael. I really appreciate your help.
Below code will allow us to declare optional date field.
<xs:element name="ConDt" maxOccurs="unbounded" minOccurs="0">
<xs:simpleType>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="0" />
<xs:maxLength value="0" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:date" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>

xsd attribute minOccurs="0" is not working for type="xsd:dateTime"

In my wsdl i want the date field to be optional for that in the wsdl i gave
<xsd:element maxOccurs="1" minOccurs="0" name="Date" type="xsd:dateTime" nillable="true" >
</xsd:element>
but its is not working.it is expecting value in this field.How make a dateTime field optional?can anyone please help
Try removing the nillable attribute, keeping the minOccurs.

Unmarshal xhtml as string using xsd

I'm trying to unmarshal a large xhtml document using XSD's and jaxb. I've got everything working except for one part, which contains pure html. Here is an example of the xhtml I'm getting (I am able to grab every element except the "content"):
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text">...</title>
<id>...</id>
<updated>...</updated>
<entry>
<id>...</id>
<title type="text">...</title>
<updated>...</updated>
<author>
<name>...</name>
</author>
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
<div>{html...}<div>{html...}</div>/<div>/<div>
</content>
</entry>
</feed>
Here's an expansion of the xsd file:
<xsd:complexType name="ApCategoriesJAXB" >
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="updated" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="link" type="tns:ApLinkJAXB" minOccurs="0"></xsd:element>
<xsd:element name="entry" type="tns:ApEntryJAXB" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApEntryJAXB">
<xsd:sequence>
<xsd:element name="id" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="name" type="xsd:string" minOccurs="0"></xsd:element>
<xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="updated" type="xsd:string" minOccurs="1" maxOccurs="1"></xsd:element>
<xsd:element name="author" type="tns:ApAuthorJAXB" minOccurs="0"></xsd:element>
<xsd:element name="link" type="tns:ApLinkJAXB" minOccurs="0"></xsd:element>
<xsd:element name="category" type="tns:ApCategoryJAXB" minOccurs="0"></xsd:element>
<xsd:element name="content" type="tns:ApContentJAXB" minOccurs="0"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApCategoryJAXB" >
<xsd:sequence></xsd:sequence>
<xsd:attribute name="term" type="xsd:string" />
<xsd:attribute name="label" type="xsd:string" />
<xsd:attribute name="scheme" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="ApContentJAXB" >
<xsd:sequence>
<xsd:element name="div" type="tns:ApDivJAXB" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="ApDivJAXB" >
<xsd:sequence>
<xsd:any namespace="http://www.w3.org/2005/Atom" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
I have tried every combination of nested xsd elements, complexTypes, xsd:any etc etc and cannot seem to get this "content" value no matter what I try. I am happy to take all the html as a string, or unmarshal it into an object.
Thank you in advance for any thoughts.
** I've edited the xsd part to include relevant parts. I've tried both nesting the "any" element in the "div" complexType as seen, as well as skipping the "div" complexType altogether.
Thanks again.
If you want <content> to have a type of xsd:string, you need to encode or otherwise escape the HTML. You could use CDATA sections, Base64 encoding, or escape all the entities (e.g. < to <, etc.).
Otherwise, xsd:any should work. Can you provide a more complete example of your XSD when you tried this?

SOAP HTTP Request Very Slow

Im totally new to SOAP HTTP Requests. Can someone give me a broad rundown on things that might slow it down. Im working on a .NET application that uses SOAP, WSDL. The request is taking around 50 seconds, everytime. Im probably making no sense, so please excuse my ignorance. Could there be something I could do at my end, to allow the request to run without causing the page not to load. AJAX maybe.
--M
Edit (09/08/2009):
OK, i've used SOAPUI and its coming up with two options WebServiceSoap12 and WebServiceSoap. The first one is goving me a speedy milliseconds response, and the second is giving me a "400 Bad Request. Why would I need that second one?
Below is the WSDL
<?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://www.example.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://www.example.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://www.example.com">
<s:element name="EventGetList">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="regionId" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="EventGetListResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="EventGetListResult" type="tns:ArrayOfOpenEvent" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ArrayOfOpenEvent">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="OpenEvent" nillable="true" type="tns:OpenEvent" />
</s:sequence>
</s:complexType>
<s:complexType name="OpenEvent">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Id" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Title" type="s:string" />
<s:element minOccurs="1" maxOccurs="1" name="EventStart" type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="EventEnd" type="s:dateTime" />
<s:element minOccurs="0" maxOccurs="1" name="RegionId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EventSubject" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EventAdditionalDetails" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EventDelivery" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Location" type="tns:EventLocation" />
<s:element minOccurs="1" maxOccurs="1" name="OnlineRegistrations" type="s:boolean" />
</s:sequence>
</s:complexType>
<s:complexType name="EventLocation">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Address3" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Town" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Postcode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="AddressOther" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="EventRegisterClient">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="registration" type="tns:OpenEventRegistration" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="OpenEventRegistration">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="EventId" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="ForeName" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Surname" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="TelephoneNumber" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="EmailAddress" type="s:string" />
</s:sequence>
</s:complexType>
<s:element name="EventRegisterClientResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="EventRegisterClientResult" type="s:boolean" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="EventGetListSoapIn">
<wsdl:part name="parameters" element="tns:EventGetList" />
</wsdl:message>
<wsdl:message name="EventGetListSoapOut">
<wsdl:part name="parameters" element="tns:EventGetListResponse" />
</wsdl:message>
<wsdl:message name="EventRegisterClientSoapIn">
<wsdl:part name="parameters" element="tns:EventRegisterClient" />
</wsdl:message>
<wsdl:message name="EventRegisterClientSoapOut">
<wsdl:part name="parameters" element="tns:EventRegisterClientResponse" />
</wsdl:message>
<wsdl:portType name="WebServiceSBSpEventsSoap">
<wsdl:operation name="EventGetList">
<wsdl:input message="tns:EventGetListSoapIn" />
<wsdl:output message="tns:EventGetListSoapOut" />
</wsdl:operation>
<wsdl:operation name="EventRegisterClient">
<wsdl:input message="tns:EventRegisterClientSoapIn" />
<wsdl:output message="tns:EventRegisterClientSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WebServiceSBSpEventsSoap" type="tns:WebServiceSBSpEventsSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="EventGetList">
<soap:operation soapAction="http://www.example.com/EventGetList" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="EventRegisterClient">
<soap:operation soapAction="http://www.example.com/EventRegisterClient" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WebServiceSBSpEventsSoap12" type="tns:WebServiceSBSpEventsSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="EventGetList">
<soap12:operation soapAction="http://www.example.com/EventGetList" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="EventRegisterClient">
<soap12:operation soapAction="http://www.example.com/EventRegisterClient" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebServiceSBSpEvents">
<wsdl:port name="WebServiceSBSpEventsSoap" binding="tns:WebServiceSBSpEventsSoap">
<soap:address location="http://www.example.com/webserviceexternal/WebServiceSBSpEvents.asmx" />
</wsdl:port>
<wsdl:port name="WebServiceSBSpEventsSoap12" binding="tns:WebServiceSBSpEventsSoap12">
<soap12:address location="http://www.example.com/webserviceexternal/WebServiceSBSpEvents.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
You should first try to pinpoint the cause of the delay, as there could be many reasons for it. Your main interest would be if the delay happens on the side of the server or on the side of (your) client.
If the delay is on the server side of things (might be a complicated operation to create a result, might be slow server, etc.), then you can look for workarounds to deal with that in your client, e.g.:
creating the page first and pulling the data from the service afterward via ajax, as you suggested
pulling the data from the service upfront in regular intervals and storing it in a local cache from which you construct your pages
etc...
If the delay is happening on the client side, you should try to find the root cause (e.g. network configuration, timeouts with reverse lookups, etc.) and fix it ;)
Edit: Given the posted wsdl, the web service offers itself in two variations, one for 'default' SOAP and one for SOAP 1.2. The 400 response indicates that the client is issuing the request in a non standard conform way, but it might also be that the service end is not properly set up for the protocol version it says to offer in the wsdl.
As for why you'd need one or the other, the answer is simple: Both offer the exact same methods, so you only need one. It could be that the delay is caused by your client first trying to use the defunct version a couple of times and only switching to the other after a while - but this is just guesswork. If SOAPUI works ok with the 1.2 version, I'd just try to tell the client to use that and see if that speeds things up.

Resources