I am having problems making simple web service calls using Dynamic
invocation of an Axis based web service using WSIF. I have attached the
WSDL for the service to this email. The WSDL is a sample WSDL using the
WSDM spec. I am using the most recent HEAD from CVS for my WSIF
implementation.
I am trying to make a dynamic invocation call on the
GetResourceProperty operation. This operation imports its input and
output messages from the WSRP WSDL.
<portType name="DiskPortType"
wsrp:ResourceProperties="tns:DiskProperties">
<operation name="GetResourceProperty">
<input name="GetResourcePropertyRequest"
message="wsrp:GetResourcePropertyRequest"/>
<output name="GetResourcePropertyResponse"
message="wsrp:GetResourcePropertyResponse"/>
<fault name="ResourceUnknownFault"
message="wsrp:ResourceUnknownFault"/>
<fault name="InvalidResourcePropertyQNameFault"
message="wsrp:InvalidResourcePropertyQNameFault"/>
</operation>
The first problem I encountered was that the imported schemas were not
being pulled in unless I set the following features.
factory.setFeature(WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES,
Boolean.TRUE);
char[] chars = new char[0];
factory.setFeature(WSIFConstants.WSIF_FEATURE_PROXY_AUTHENTICATION, new
PasswordAuthentication("", chars));
Unless these were set, my imported schemas were being ignored (See
WSIFServiceImpl constructor and .init()). I am not using authentication
at all. Is there a better way to get my WSDL information imported?
My second problem is in actually being able to fill in the fields of the
input message. I have tried many combinations of input.setObjectPart but
do not seem able to fill in the input document properly. The schema
fragment for wsrp:GetResourceProeprtyRequest is ...
<xsd:element name="GetResourcePropertyRequest"
type="xsd:QName" />
which is pretty straight forward, but it is from an external document.
I attempt to set a QName for this value by doing a....
QName qn = new QName("http://xyz.com/","BlockSize");
input.setObjectPart("GetResourcePropertyRequest",qn);
and get the following:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<prop:To
xmlns:prop="http://my.org/uri/">http://localhost:8080/wsdm</prop:To>
<prop:Action
xmlns:prop="http://my.org/uri/">http://schemas.xmlsoap.org/ws/2004/03/addressing</prop:Action>
<prop:ResourceID
xmlns:prop="http://my.org/uri/">1234</prop:ResourceID>
</soapenv:Header>
<soapenv:Body>
<GetResourcePropertyRequest xsi:type="xsd:QName" xmlns=""
xmlns:ns1="http://xyz.com/">ns1:BlockSize</GetResourcePropertyRequest>
</soapenv:Body>
</soapenv:Envelope>
The problem with this document is that GetResourcePropertyRequest
namespace is not defined (xmlns=""). It also has an xsi:type attribute
which I do not want included as I am doing document style.
The only way I could get the request to look the way I needed it to was
to do the following. (Which I think defeats the purpose of using WSIF in
the first place..)
DocumentBuilderFactory docFactory =
DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
DocumentBuilder builder = null;
try {
builder = docFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Document doc = builder.newDocument();
Element elem =
doc.createElementNS("http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties",
"GetResourcePropertyRequest");
elem.setAttribute("xmlns:m","http://xyz.com");
Text text = doc.createTextNode("m:BlockSize");
elem.appendChild(text);
input.setObjectPart("GetResourcePropertyRequest",elem);
This version produced the following request which is what the WSDL
actually requires.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<prop:To
xmlns:prop="http://my.org/uri/">http://localhost:8080/wsdm</prop:To>
<prop:Action
xmlns:prop="http://my.org/uri/">http://schemas.xmlsoap.org/ws/2004/03/addressing</prop:Action>
<prop:ResourceID
xmlns:prop="http://my.org/uri/">1234</prop:ResourceID>
</soapenv:Header>
<soapenv:Body>
<ns1:GetResourcePropertyRequest xmlns:m="http://xyz.com"
xmlns:ns1="http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties">m:BlockSize</ns1:GetResourcePropertyRequest>
</soapenv:Body>
</soapenv:Envelope>
Notice there is no longer any xsi:type and GetResourcePropertyRequest
is qualified now.
Am I using WSIF incorrectly or is this the only way I can build this
request?
Thanks in advance,
<?xml version="1.0"?>
<definitions name="WsdmWebServiceDefinition" targetNamespace="http://xyz.com/"
xmlns:tns="http://xyz.com/" xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsrp="http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties"
xmlns:wsnt="http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification"
xmlns:wstop="http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics"
xmlns:muws-wsdl="http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/wsdl">
<import namespace="http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties"
location="http://www-106.ibm.com/developerworks/webservices/library/ws-resource/WS-ResourceProperties.wsdl" />
<import namespace="http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification"
location="http://www-106.ibm.com/developerworks/library/specification/ws-notification/WS-BaseN.wsdl" />
<import namespace="http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/wsdl"
location="http://mip.esr.hp.com/wsdm/wsdl/MUWS.wsdl" />
<types>
<schema elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://xyz.com/" xmlns:tns="http://xyz.com/"
xmlns:muws-xs="http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/schema"
schemaLocation="http://mip.esr.hp.com/wsdm/wsdl/MUWS.xsd" />
<!-- NOTE: Schema on devresource has invalid reference to BaseNotification XSD -->
<xsd:import namespace="http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics"
schemaLocation="http://mip.esr.hp.com/wsdm/wsdl/WS-Topics-1-0.xsd" />
<element name="Manufacturer" type="xsd:string"/>
<element name="BlockSize" type="xsd:int"/>
<element name="NumberOfBlocks" type="xsd:integer"/>
<element name="FileSystem" type="xsd:string" />
<element name="StateInfo" type="muws-xs:StateInformation" />
<element name="TopicSpace" type="wstop:TopicSpaceType"/>
<element name="DiskProperties">
<complexType>
<sequence>
<element ref="muws-xs:ResourceId"/>
<element ref="muws-xs:Name" minOccurs="0"/>
<element ref="muws-xs:Version" minOccurs="0"/>
<element ref="muws-xs:ResourceState"/>
<element ref="muws-xs:CurrentTime"/>
<element ref="tns:Manufacturer" minOccurs="0"/>
<element ref="tns:BlockSize"/>
<element ref="tns:NumberOfBlocks"/>
<element ref="tns:FileSystem" minOccurs="1" maxOccurs="2" />
<element ref="tns:StateInfo" minOccurs="0" maxOccurs="unbounded" />
<!-- NotificationProducer Resource Properties -->
<element ref="wsnt:Topic" minOccurs="1" maxOccurs="unbounded" />
<element ref="wsnt:FixedTopicSet" minOccurs="1" maxOccurs="1" />
<element ref="wsnt:TopicExpressionDialects" minOccurs="1" maxOccurs="unbounded" />
<!-- Resource Property Change Notification Property -->
<element ref="tns:TopicSpace" minOccurs="1" maxOccurs="unbounded"/>
<any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<portType name="DiskPortType" wsrp:ResourceProperties="tns:DiskProperties">
<operation name="GetResourceProperty">
<input name="GetResourcePropertyRequest" message="wsrp:GetResourcePropertyRequest"/>
<output name="GetResourcePropertyResponse" message="wsrp:GetResourcePropertyResponse"/>
<fault name="ResourceUnknownFault" message="wsrp:ResourceUnknownFault"/>
<fault name="InvalidResourcePropertyQNameFault" message="wsrp:InvalidResourcePropertyQNameFault"/>
</operation>
<operation name="GetMultipleResourceProperties">
<input name="GetMultipleResourcePropertiesRequest" message="wsrp:GetMultipleResourcePropertiesRequest"/>
<output name="GetMultipleResourcePropertiesResponse" message="wsrp:GetMultipleResourcePropertiesResponse"/>
<fault name="ResourceUnknownFault" message="wsrp:ResourceUnknownFault"/>
<fault name="InvalidResourcePropertyQNameFault" message="wsrp:InvalidResourcePropertyQNameFault"/>
</operation>
<operation name="SetResourceProperties">
<input name="SetResourcePropertiesRequest" message="wsrp:SetResourcePropertiesRequest"/>
<output name="SetResourcePropertiesResponse" message="wsrp:SetResourcePropertiesResponse"/>
<fault name="ResourceUnknownFault" message="wsrp:ResourceUnknownFault"/>
<fault name="InvalidResourcePropertyQNameFault" message="wsrp:InvalidResourcePropertyQNameFault"/>
<fault name="InvalidSetResourcePropertiesRequestContentFault" message="wsrp:InvalidSetResourcePropertiesRequestContentFault"/>
<fault name="UnableToModifyResourcePropertyFault" message="wsrp:UnableToModifyResourcePropertyFault"/>
<fault name="SetResourcePropertyRequestFailedFault" message="wsrp:SetResourcePropertyRequestFailedFault"/>
</operation>
<operation name="QueryResourceProperties">
<input name="QueryResourcePropertiesRequest" message="wsrp:QueryResourcePropertiesRequest"/>
<output name="QueryResourcePropertiesResponse" message="wsrp:QueryResourcePropertiesResponse"/>
<fault name="ResourceUnknownFault" message="wsrp:ResourceUnknownFault"/>
<fault name="InvalidResourcePropertyQNameFault" message="wsrp:InvalidResourcePropertyQNameFault"/>
<fault name="UnknownQueryExpressionDialectFault" message="wsrp:UnknownQueryExpressionDialectFault"/>
<fault name="InvalidQueryExpressionFault" message="wsrp:InvalidQueryExpressionFault"/>
<fault name="QueryEvaluationErrorFault" message="wsrp:QueryEvaluationErrorFault"/>
</operation>
<operation name="Start">
<input name="StartRequest" message="muws-wsdl:StartRequest"/>
<output name="StartResponse" message="muws-wsdl:StartResponse"/>
</operation>
<operation name="Stop">
<input name="StopRequest" message="muws-wsdl:StopRequest"/>
<output name="StopResponse" message="muws-wsdl:StopResponse"/>
</operation>
<operation name="ResetAll">
<input name="ResetAllRequest" message="muws-wsdl:ResetAllRequest"/>
<output name="ResetAllResponse" message="muws-wsdl:ResetAllResponse"/>
</operation>
<!-- NotificationProducer Operations -->
<operation name="Subscribe">
<input message="wsnt:SubscribeRequest" />
<output message="wsnt:SubscribeResponse" />
<fault name="ResourceUnknownFault" message="wsnt:ResourceUnknownFault" />
<fault name="SubscribeCreationFailedFault" message="wsnt:SubscribeCreationFailedFault" />
<fault name="TopicPathDialectUnknownFault" message="wsnt:TopicPathDialectUnknownFault" />
</operation>
<operation name="GetCurrentMessage">
<input message="wsnt:GetCurrentMessageRequest" />
<output message="wsnt:GetCurrentMessageResponse" />
<fault name="ResourceUnknownFault" message="wsnt:ResourceUnknownFault" />
<fault name="InvalidTopicExpressionFault" message="wsnt:InvalidTopicExpressionFault" />
<fault name="TopicNotSupportedFault" message="wsnt:TopicNotSupportedFault" />
<fault name="NoCurrentMessageOnTopicFault" message="wsnt:NoCurrentMessageOnTopicFault" />
</operation>
</portType>
<binding name="DiskSoapHttpBinding" type="tns:DiskPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetResourceProperty">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="InvalidResourcePropertyQNameFault">
<soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
</fault>
</operation>
<operation name="GetMultipleResourceProperties">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="InvalidResourcePropertyQNameFault">
<soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
</fault>
</operation>
<operation name="SetResourceProperties">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="InvalidResourcePropertyQNameFault">
<soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
</fault>
<fault name="UnableToModifyResourcePropertyFault">
<soap:fault name="UnableToModifyResourcePropertyFault" use="literal"/>
</fault>
<fault name="InvalidSetResourcePropertiesRequestContentFault">
<soap:fault name="InvalidSetResourcePropertiesRequestContentFault" use="literal"/>
</fault>
<fault name="SetResourcePropertyRequestFailedFault">
<soap:fault name="SetResourcePropertyRequestFailedFault" use="literal"/>
</fault>
</operation>
<operation name="QueryResourceProperties">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="InvalidResourcePropertyQNameFault">
<soap:fault name="InvalidResourcePropertyQNameFault" use="literal"/>
</fault>
<fault name="UnknownQueryExpressionDialectFault">
<soap:fault name="UnknownQueryExpressionDialectFault" use="literal"/>
</fault>
<fault name="InvalidQueryExpressionFault">
<soap:fault name="InvalidQueryExpressionFault" use="literal"/>
</fault>
<fault name="QueryEvaluationErrorFault">
<soap:fault name="QueryEvaluationErrorFault" use="literal"/>
</fault>
</operation>
<operation name="Start">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Stop">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="ResetAll">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Subscribe">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="SubscribeCreationFailedFault">
<soap:fault name="SubscribeCreationFailedFault" use="literal"/>
</fault>
<fault name="TopicPathDialectUnknownFault">
<soap:fault name="TopicPathDialectUnknownFault" use="literal"/>
</fault>
</operation>
<operation name="GetCurrentMessage">
<soap:operation style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="ResourceUnknownFault">
<soap:fault name="ResourceUnknownFault" use="literal"/>
</fault>
<fault name="InvalidTopicExpressionFault">
<soap:fault name="InvalidTopicExpressionFault" use="literal"/>
</fault>
<fault name="TopicNotSupportedFault">
<soap:fault name="TopicPathDialectUnknownFault" use="literal"/>
</fault>
<fault name="NoCurrentMessageOnTopicFault">
<soap:fault name="NoCurrentMessageOnTopicFault" use="literal"/>
</fault>
</operation>
</binding>
<service name="DiskWsdmService">
<port name="disk" binding="tns:DiskSoapHttpBinding">
<soap:address location="http://localhost:8080/wsdm/services/disk"/>
</port>
</service>
</definitions>