I'm trying to create a soap web service client in C using gSoap under Windows server 2022.
I tried to use wsdl2h to convert WSDL file to generate interface header files for soapcpp2, but I obtained an empty file.
When I execute wsdl2h I have this message:
The WSDL file is:
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:eda-sw-schemas/page/salesorder" targetNamespace="urn:eda-sw-schemas/page/salesorder">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:eda-sw-schemas/page/salesorder">
<xsd:simpleType name="Job_Queue_Status">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_blank_"/>
<xsd:enumeration value="Scheduled_for_Posting"/>
<xsd:enumeration value="Error"/>
<xsd:enumeration value="Posting"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Status">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Open"/>
<xsd:enumeration value="Released"/>
<xsd:enumeration value="Pending_Approval"/>
<xsd:enumeration value="Pending_Prepayment"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Prepmt_CM_Refers_to_Period">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_blank_"/>
<xsd:enumeration value="Current"/>
<xsd:enumeration value="Current_Calendar_Year"/>
<xsd:enumeration value="Previous_Calendar_Year"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_blank_"/>
<xsd:enumeration value="G_L_Account"/>
<xsd:enumeration value="Item"/>
<xsd:enumeration value="Resource"/>
<xsd:enumeration value="Fixed_Asset"/>
<xsd:enumeration value="Charge_Item"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="IC_Partner_Ref_Type">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_blank_"/>
<xsd:enumeration value="G_L_Account"/>
<xsd:enumeration value="Item"/>
<xsd:enumeration value="Charge_Item"/>
<xsd:enumeration value="Cross_Reference"/>
<xsd:enumeration value="Common_Item_No"/>
<xsd:enumeration value="Vendor_Item_No"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="Prepmt_CM_Refers_to_Period_12139">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="_blank_"/>
<xsd:enumeration value="Current"/>
<xsd:enumeration value="Current_Calendar_Year"/>
<xsd:enumeration value="Previous_Calendar_Year"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="Sales_Order_Line">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="Key" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Type" type="tns:Type"/>
<xsd:element minOccurs="0" maxOccurs="1" name="FilteredTypeField" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="No" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Include_in_VAT_Transac_Rep" type="xsd:boolean"/>
<xsd:element minOccurs="0" maxOccurs="1" name="IC_Partner_Ref_Type" type="tns:IC_Partner_Ref_Type"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Prepmt_CM_Refers_to_Period" type="tns:Prepmt_CM_Refers_to_Period_12139"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Requested_Delivery_Date" type="xsd:date"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Whse_Outstanding_Qty" type="xsd:decimal"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Appl_from_Item_Entry" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Sales_Order_Line_List">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="unbounded" name="Sales_Order_Line" type="tns:Sales_Order_Line"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SalesOrder">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="Key" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="No" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Sell_to_Customer_No" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Sell_to_Customer_Name" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Job_Queue_Status" type="tns:Job_Queue_Status"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Status" type="tns:Status"/>
<xsd:element minOccurs="0" maxOccurs="1" name="SalesLines" type="tns:Sales_Order_Line_List"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SalesOrder_List">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="unbounded" name="SalesOrder" type="tns:SalesOrder"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="SalesOrder_Fields">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="No"/>
<xsd:enumeration value="Sell_to_Customer_No"/>
<xsd:enumeration value="Sell_to_Customer_Name"/>
<xsd:enumeration value="Job_Queue_Status"/>
<xsd:enumeration value="Status"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="SalesOrder_Filter">
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="Field" type="tns:SalesOrder_Fields"/>
<xsd:element minOccurs="1" maxOccurs="1" name="Criteria" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ReadMultiple">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="unbounded" name="filter" type="tns:SalesOrder_Filter"/>
<xsd:element minOccurs="0" maxOccurs="1" name="bookmarkKey" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="setSize" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="ReadMultiple_Result">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="1" name="ReadMultiple_Result" type="tns:SalesOrder_List"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="ReadMultiple">
<part name="parameters" element="tns:ReadMultiple"/>
</message>
<message name="ReadMultiple_Result">
<part name="parameters" element="tns:ReadMultiple_Result"/>
</message>
<portType name="SalesOrder_Port">
<operation name="ReadMultiple">
<input name="ReadMultiple" message="tns:ReadMultiple"/>
<output name="ReadMultiple_Result" message="tns:ReadMultiple_Result"/>
</operation>
</portType>
<binding name="SalesOrder_Binding" type="tns:SalesOrder_Port">
<binding xmlns="http://schemas.xmlsoap.org/wsdl/soap/" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ReadMultiple">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:eda-sw-schemas/page/salesorder:ReadMultiple" style="document"/>
<input name="ReadMultiple">
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</input>
<output name="ReadMultiple_Result">
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</output>
</operation>
</binding>
<service name="SalesOrder_Service">
I tried under linux and the .h files are correctly generated.
what I'm doing wrong ?
Related
I’m trying develop SOAP web service client using spring-ws-2.2.0 & spring-boot-1.1.8 in a standalone app, but I get this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'marshaller' defined in class pcc_load.ApexConfiguration: Invocation of init method
failed; nested exception is org.springframework.oxm.UncategorizedMappingException:
Unknown JAXB exception; nested exception is javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated:
javax.xml.bind.JAXBException: "pcc_load/src/com/company/dept/apex/stubs/ObjectFactory.java" doesnt contain ObjectFactory.class or jaxb.index
- with linked exception:
[javax.xml.bind.JAXBException: "pcc_load/src/com/company/department/apex/stubs/ObjectFactory.java" doesnt contain ObjectFactory.class or jaxb.index]
I created all the stubs using ant & the wsdl without any error, here is the wsdl:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="PCCDATA_APEX_WS" xmlns:tns1="dsws.businessobjects.com"
targetNamespace="PCCDATA_APEX_WS" xmlns="http://schemas.xmlsoap.org/wsdl/"
name="BIServices">
<types>
<s:schema elementFormDefault="qualified" targetNamespace="PCCDATA_APEX_WS">
<s:simpleType name="Operator">
<s:restriction base="s:string">
<s:enumeration value="EQUAL" />
<s:enumeration value="GREATER" />
<s:enumeration value="GREATER_OR_EQUAL" />
<s:enumeration value="LESS" />
<s:enumeration value="LESS_OR_EQUAL" />
<s:enumeration value="NOT_EQUAL" />
<s:enumeration value="INLIST" />
<s:enumeration value="NOT_INLIST" />
</s:restriction>
</s:simpleType>
<s:complexType name="FilterCondition">
<s:sequence>
<s:element name="value" type="s:string" />
<s:element name="operator" type="s0:Operator" />
</s:sequence>
</s:complexType>
<s:complexType name="LovValueIndex">
<s:sequence>
<s:element name="valueofPrompt" type="s:string" />
<s:element name="index" type="s:string" />
</s:sequence>
</s:complexType>
<s:complexType name="DrillFilter">
<s:sequence>
<s:element name="dimension" type="s:string" />
<s:element name="value" type="s:string" />
<s:element name="operator" type="s0:Operator" />
</s:sequence>
</s:complexType>
<s:element name="GetReportBlock_PCCDATA_APEX_WS">
<s:complexType>
<s:sequence>
<s:element name="login" type="s:string" minOccurs="0"
nillable="true" />
<s:element name="password" type="s:string" minOccurs="0"
nillable="true" />
<s:element name="_Business_Segment__Multiple__Optional_"
type="s0:LovValueIndex" minOccurs="0" maxOccurs="unbounded"
nillable="true" />
<s:element name="resetState" type="s:boolean" minOccurs="0"
nillable="true" />
<s:element name="refresh" type="s:boolean" minOccurs="0"
nillable="true" />
<s:element name="getFromLatestDocumentInstance" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="getFromUserInstance" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="turnOutputToVTable" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="closeDocument" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="startRow" type="s:int" minOccurs="0"
nillable="true" />
<s:element name="endRow" type="s:int" minOccurs="0"
nillable="true" />
</s:sequence>
</s:complexType>
</s:element>
<s:simpleType name="DrillOperation">
<s:restriction base="s:string">
<s:enumeration value="UP" />
<s:enumeration value="DOWN" />
</s:restriction>
</s:simpleType>
<s:complexType name="DrillPath">
<s:sequence>
<s:element name="from" type="s:string" />
<s:element name="value" type="s:string" />
<s:element name="drillOperation" type="s0:DrillOperation" />
</s:sequence>
</s:complexType>
<s:element name="Drill_PCCDATA_APEX_WS">
<s:complexType>
<s:sequence>
<s:element name="login" type="s:string" minOccurs="0"
nillable="true" />
<s:element name="password" type="s:string" minOccurs="0"
nillable="true" />
<s:element name="drillPath" type="s0:DrillPath"
minOccurs="0" maxOccurs="unbounded" nillable="true" />
<s:element name="filter" type="s0:DrillFilter"
minOccurs="0" maxOccurs="unbounded" nillable="true" />
<s:element name="_Business_Segment__Multiple__Optional_"
type="s0:LovValueIndex" minOccurs="0" maxOccurs="unbounded"
nillable="true" />
<s:element name="resetState" type="s:boolean" minOccurs="0"
nillable="true" />
<s:element name="refresh" type="s:boolean" minOccurs="0"
nillable="true" />
<s:element name="getFromLatestDocumentInstance" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="getFromUserInstance" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="turnOutputToVTable" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="closeDocument" type="s:boolean"
minOccurs="0" nillable="true" />
<s:element name="startRow" type="s:int" minOccurs="0"
nillable="true" />
<s:element name="endRow" type="s:int" minOccurs="0"
nillable="true" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="TRow">
<s:sequence>
<s:element name="cell" type="s:anyType" maxOccurs="unbounded"
nillable="true" />
</s:sequence>
</s:complexType>
<s:complexType name="TTable">
<s:sequence>
<s:element name="row" maxOccurs="unbounded" type="s0:TRow" />
</s:sequence>
</s:complexType>
<s:complexType name="THeader">
<s:sequence>
<s:element name="row" maxOccurs="unbounded" type="s0:TRow" />
</s:sequence>
</s:complexType>
<s:complexType name="TFooter">
<s:sequence>
<s:element name="row" maxOccurs="unbounded" type="s0:TRow" />
</s:sequence>
</s:complexType>
<s:element name="GetReportBlock_PCCDATA_APEX_WSResponse">
<s:complexType>
<s:sequence>
<s:element name="table" type="s0:TTable" />
<s:element name="headers" type="s0:THeader" />
<s:element name="footers" type="s0:TFooter" />
<s:element name="user" type="s:string" />
<s:element name="documentation" type="s:string" />
<s:element name="documentname" type="s:string" />
<s:element name="lastrefreshdate" type="s:dateTime" />
<s:element name="creationdate" type="s:dateTime" />
<s:element name="creator" type="s:string" />
<s:element name="isScheduled" type="s:boolean" />
<s:element name="scheduleStartTime" type="s:dateTime" />
<s:element name="scheduleEndTime" type="s:dateTime" />
<s:element name="tableType" type="s:string" />
<s:element name="nbColumns" type="s:int" />
<s:element name="nbLines" type="s:int" />
<s:element name="message" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="Drill_PCCDATA_APEX_WSResponse">
<s:complexType>
<s:sequence>
<s:element name="table" type="s0:TTable" />
<s:element name="headers" type="s0:THeader" />
<s:element name="footers" type="s0:TFooter" />
<s:element name="user" type="s:string" />
<s:element name="documentation" type="s:string" />
<s:element name="documentname" type="s:string" />
<s:element name="lastrefreshdate" type="s:dateTime" />
<s:element name="creationdate" type="s:dateTime" />
<s:element name="creator" type="s:string" />
<s:element name="isScheduled" type="s:boolean" />
<s:element name="scheduleStartTime" type="s:dateTime" />
<s:element name="scheduleEndTime" type="s:dateTime" />
<s:element name="tableType" type="s:string" />
<s:element name="nbColumns" type="s:int" />
<s:element name="nbLines" type="s:int" />
<s:element name="message" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="QaaWSHeader">
<s:complexType>
<s:sequence>
<s:element name="sessionID" type="s:string" minOccurs="0"
maxOccurs="1" nillable="true" />
<s:element name="serializedSession" type="s:string"
minOccurs="0" maxOccurs="1" nillable="true" />
<s:element name="ClientType" type="s:string" minOccurs="0"
maxOccurs="1" nillable="true" />
<s:element name="AuditingObjectID" type="s:string"
minOccurs="0" maxOccurs="1" nillable="true" />
<s:element name="AuditingObjectName" type="s:string"
minOccurs="0" maxOccurs="1" nillable="true" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="GetReportBlock_PCCDATA_APEX_WSSoapIn">
<part name="parameters" element="s0:GetReportBlock_PCCDATA_APEX_WS" />
<part name="request_header" element="s0:QaaWSHeader" />
</message>
<message name="GetReportBlock_PCCDATA_APEX_WSSoapOut">
<part name="parameters" element="s0:GetReportBlock_PCCDATA_APEX_WSResponse" />
</message>
<message name="Drill_PCCDATA_APEX_WSSoapIn">
<part name="parameters" element="s0:Drill_PCCDATA_APEX_WS" />
<part name="request_header" element="s0:QaaWSHeader" />
</message>
<message name="Drill_PCCDATA_APEX_WSSoapOut">
<part name="parameters" element="s0:Drill_PCCDATA_APEX_WSResponse" />
</message>
<portType name="BIServicesSoap">
<operation name="GetReportBlock_PCCDATA_APEX_WS">
<documentation></documentation>
<input message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn" />
<output message="s0:GetReportBlock_PCCDATA_APEX_WSSoapOut" />
</operation>
<operation name="Drill_PCCDATA_APEX_WS">
<documentation></documentation>
<input message="s0:Drill_PCCDATA_APEX_WSSoapIn" />
<output message="s0:Drill_PCCDATA_APEX_WSSoapOut" />
</operation>
</portType>
<binding name="BIServicesSoap" type="s0:BIServicesSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="GetReportBlock_PCCDATA_APEX_WS">
<documentation></documentation>
<soap:operation soapAction="PCCDATA_APEX_WS/GetReportBlock_PCCDATA_APEX_WS"
style="document" />
<input>
<soap:header message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn"
part="request_header" use="literal">
<soap:headerfault message="s0:GetReportBlock_PCCDATA_APEX_WSSoapIn"
part="request_header" use="literal" />
</soap:header>
<soap:body use="literal" parts="parameters" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
<operation name="Drill_PCCDATA_APEX_WS">
<documentation></documentation>
<soap:operation soapAction="PCCDATA_APEX_WS/Drill_PCCDATA_APEX_WS"
style="document" />
<input>
<soap:header message="s0:Drill_PCCDATA_APEX_WSSoapIn"
part="request_header" use="literal">
<soap:headerfault message="s0:Drill_PCCDATA_APEX_WSSoapIn"
part="request_header" use="literal" />
</soap:header>
<soap:body use="literal" parts="parameters" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<service name="PCCDATA_APEX_WS">
<documentation></documentation>
<port name="BIServicesSoap" binding="s0:BIServicesSoap">
<soap:address
location="http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&authType=secEnterprise&locale=en&timeout=60&ConvertAnyType=true" />
</port>
</service>
</definitions>
I used this tutorial/guide from spring:
https://spring.io/guides/gs/consuming-web-service/
Here is my main:
import org.springframework.context.ApplicationContext;
import org.springframework.boot.SpringApplication;
public class main {
public static void main (String [] args)
{
ApplicationContext ctx = SpringApplication.run(ApexConfiguration.class);
apexClient newApexClient = ctx.getBean(apexClient.class);
newApexClient.callDrillPCCDATAAPEXWS();
}
}
Here is my Jaxb2Marshaller configuration class:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
#Configuration
public class ApexConfiguration {
#Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
/* I tried these values but getting the same error?
* 1) "apex.wsdl"
* or
* 2) "/apex.wsdl"
3) "com.company.dept.apex.stubs"
* or
* 4) fully qualified package that stubs are generated in "com.company.dept.apex.stubs.ObjectFactory"
*/
marshaller.setContextPath("apex.wsdl");
return marshaller;
}
#Bean
public apexClient weatherClient(Jaxb2Marshaller marshaller) {
apexClient client = new apexClient();
client.setDefaultUri("http://xyz.test.app.company.com:8080");
client.setMarshaller(marshaller);
client.setUnmarshaller(marshaller);
return client;
}
}
Here is the actual client web service implementation & request calls:
import javax.xml.bind.JAXBElement;
import org.springframework.ws.client.core.WebServiceTemplate;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.soap.client.core.SoapActionCallback;
import org.springframework.beans.factory.InitializingBean;
import com.company.dept.apex.stubs.DrillPCCDATAAPEXWS;
import com.company.dept.apex.stubs.DrillPCCDATAAPEXWSResponse;
import com.company.dept.apex.stubs.GetReportBlockPCCDATAAPEXWS;
import com.company.dept.apex.stubs.GetReportBlockPCCDATAAPEXWSResponse;
import com.company.dept.apex.stubs.ObjectFactory;
public class apexClient extends WebServiceGatewaySupport {
private WebServiceTemplate webServiceTemplate;
//ZBIJOB248/testme05
public String username="user1234";
public String pass="pass1234";
public DrillPCCDATAAPEXWSResponse callDrillPCCDATAAPEXWS()
{
setDefaultUri("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&authType=secEnterprise&locale=en&timeout=60&ConvertAnyType=true");
DrillPCCDATAAPEXWS request = new DrillPCCDATAAPEXWS();
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<String> login = objectFactory.createDrillPCCDATAAPEXWSLogin(username);
JAXBElement<String> password = objectFactory.createDrillPCCDATAAPEXWSPassword(pass);
request.setLogin(login);
request.setPassword(password);
//
DrillPCCDATAAPEXWSResponse response =
(DrillPCCDATAAPEXWSResponse) getWebServiceTemplate().marshalSendAndReceive(
request, new SoapActionCallback("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&authType=secEnterprise&locale=en&timeout=60&ConvertAnyType=true"));
return response;
}
public GetReportBlockPCCDATAAPEXWSResponse callGetReportBlockPCCDATAAPEXWSResponse()
{
setDefaultUri("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&authType=secEnterprise&locale=en&timeout=60&ConvertAnyType=true");
GetReportBlockPCCDATAAPEXWS request = new GetReportBlockPCCDATAAPEXWS();
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<String> login = objectFactory.createDrillPCCDATAAPEXWSLogin(username);
JAXBElement<String> password = objectFactory.createDrillPCCDATAAPEXWSPassword(pass);
request.setLogin(login);
request.setPassword(password);
//
GetReportBlockPCCDATAAPEXWSResponse response = (GetReportBlockPCCDATAAPEXWSResponse) getWebServiceTemplate().marshalSendAndReceive(
request, new SoapActionCallback("http://xyz.test.app.company.com:8080/dswsbobje/qaawsservices/queryasaservice/biws?cuid=AQyF0wiLGyhNgX41XOXwiEs&authType=secEnterprise&locale=en&timeout=60&ConvertAnyType=true"));
return response;
}
}//end client
It seems the problem is with the value that I’m passing to “marshaller.setContextPath("?");” its either wrong format or not able to find it.
1) How can I fix this & any other issue with this implementation?
2) (optional) For the sake of knowledge "marshaller.setContextPath()" & also the "client.setDefaultUri()"?
Thank you all.
It seems like you already tried it, but the context path should be the package name that you generated the JAXB classes to, i.e. the package that contains the ObjectFactory. In your case, it should probably be com.company.dept.apex.stubs. The generated classes should be on the classpath.
Alternatively, instead of using the context path, you can configure a Jaxb2Marshaller by setting the classesToBeBound property and simply give the classes that you want to (un)marshal.
AS for the optional question: the context path and default URI have nothing to do with each other: the context path is for JAXB marshalling purposes; the default URI is the default URL the WebServiceTemplate connects to (if you don't supply a URL parameter that is).
I need some help with my xsd and jaxb.
My xsd leads to an working class (MyWorkingType) and the 'ProblemType', which is not generated with an enum.
As I believe, that both forms are valid, why does this not work, where is the bug (jaxb or at the keyboard?)
Edit: I add my ant-script, because Xtian could create this via maven-plugin.
This is my xsd:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ProblemType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="workingEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="MyWorkingType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute" type="workingEnum" />
</xs:sequence>
</xs:complexType>
</xs:schema>
This is my ant-script I use within eclipse:
<?xml version="1.0" encoding="UTF-8"?>
<project name="generate" default="generate-jaxb" basedir=".">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<fileset dir="../lib" includes="*.jar" />
</classpath>
</taskdef>
<target name="generate-jaxb">
<xjc destdir="../../src-gen" package="test.gen">
<arg value="-no-header" />
<schema dir="xsd/" includes="*.xsd"/>
</xjc>
</target>
</project>
Try specifying typesafeEnumBase. This is what I normally do when generating mappings:
<jaxb:bindings schemaLocation="mySchema.xsd"
node="/xs:schema">
<jaxb:globalBindings
fixedAttributeAsConstantProperty="false"
typesafeEnumBase="xs:string"
typesafeEnumMemberName="generateName"
generateIsSetMethod="true">
<xjc:noValidator />
<xjc:noValidatingUnmarshaller />
</jaxb:globalBindings>
<jaxb:schemaBindings>
<jaxb:package name="my.package.name"/>
</jaxb:schemaBindings>
</jaxb:bindings>
However I don't think this is the cause.
Since my maven-jaxb2-plugin works and xjc via Ant does not, the question, what is the difference.
Actually, strict, verbose and extension settings should make no difference for enums.
However it may be that maven-jaxb2-plugin uses a newer version of xjc than you're using with enum. Please try to update your xjc and see if it helps.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ProblemType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute">
<xs:simpleType name="problemTypeEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="workingEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="MyWorkingType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true" type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute" type="workingEnum" />
</xs:sequence>
</xs:complexType>
</xs:schema>
I generated the class by this maven plugin
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.0</version>
<executions>
<execution>
<id>commun-generate</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generateDirectory>${basedir}/src/main/java/</generateDirectory>
<schemaDirectory>${basedir}/src/main/resources/schema/xsd</schemaDirectory>
<strict>false</strict>
<extension>true</extension>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
ProblemTypeEnum.java
#XmlType(name = "problemTypeEnum")
#XmlEnum
public enum ProblemTypeEnum {
VALUE_1,
VALUE_2,
VALUE_3;
public String value() {
return name();
}
public static ProblemTypeEnum fromValue(String v) {
return valueOf(v);
}
}
If you can change the structure .. this is the xsd
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ProblemType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true"
type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute"
type="problemTypeEnum" />
</xs:sequence>
</xs:complexType>
<xs:simpleType name="problemTypeEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="workingEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="VALUE_1" />
<xs:enumeration value="VALUE_2" />
<xs:enumeration value="VALUE_3" />
</xs:restriction>
</xs:simpleType>
<xs:complexType name="MyWorkingType">
<xs:sequence>
<xs:element minOccurs="0" name="normalAttribute" nillable="true"
type="xs:boolean" />
<xs:element minOccurs="1" maxOccurs="1" name="enumAttribute"
type="workingEnum" />
</xs:sequence>
</xs:complexType>
</xs:schema>
I have foo.xml, I would like to generate foo.xsd as it is generated with VisualStudio->Xml->CreateSchema, tried xsd.exe but results are not the same. (xsd.exe foo.xml)
How to call same command as VisualStudio->Xml->CreateSchema from command line?
Maybe one small example will help, notce type="xs:string" minOccurs="0" When xml is more complexed differences become huge.
xml:
<foo>
<x />
<y />
</foo>
VS:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element name="x" />
<xs:element name="y" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
xsd.exe
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element name="x" type="xs:string" minOccurs="0" />
<xs:element name="y" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="foo" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Looks like it could be that Visual Studio is using XmlSchemaInference.InferSchema internally instead of xsd.exe? More information on XmlSchemaInference.InferSchema.
I am a newbie for SAVON and ruby this is my first assignment from my client. So any help is greatly appreciated.
<complexType name="CEvent">
<annotation>
<documentation>The base used for all events. All events extend this structure.</documentation>
</annotation>
<complexContent>
<extension base="ttns:CItemWithDBRecordId">
<sequence>
<element name="user" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="date" type="xsd:dateTime" minOccurs="1" maxOccurs="1" nillable="false" />
<element name="notes" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="eventaddorder" type="xsd:short" minOccurs="1" maxOccurs="1" />
<element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="parenteventid" type="xsd:long" minOccurs="0" maxOccurs="1" />
<element name="attachmentlist" type="ttns:ArrayOfCFileAttachment" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="fieldlist" type="ttns:ArrayOfCField" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="resultingstate" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="hours" type="xsd:double" minOccurs="0" maxOccurs="1" />
<element name="assigntolist" type="ttns:ArrayOfstring" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="releasenotesversion" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="generatedeventtype" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="generatedbyname" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="totaltimespent" type="xsd:double" minOccurs="0" maxOccurs="1" />
<element name="overrideuser" type="xsd:string" minOccurs="0" maxOccurs="1" nillable="true" />
<element name="marksuspect" type="xsd:boolean" minOccurs="0" maxOccurs="1" />
</sequence>
</extension>
</complexContent>
</complexType>
and i dont know how to get that and also need to update the fields of the elements with my input data.
I am accessing it the Complex name this way.
response = #client.request 'CEvent'
and the response that i got is
(SOAP-ENV:Client) Method 'ins0:CEvent' not implemented: method name or namespac
not recognized
Im sure that this is not the way,as its not a method name , so im still scratching my head to resolve this.!!
I just recently completed a project using SAVON to access SOAP services on Microsoft SharePoint. You should be able to access the response data using the hash value returned by the Savon request.
response.hash[:annotation][:complexContent][:sequence]
Have a look at the article on my web site below. It is not specific to your requirement but might help.
http://mark.stratmann.me/content_items/using-savon-to-connect-to-microsoft-sharepoint-soap-services-in-rails-3-2
I am getting this error message when validating my XML file against its Schema. Can anyone suggest what might be wrong? The XML file is:
<?xml version="1.0"?>
<family-tree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ftree.xsd">
<person id="p5">
<name>
<given>Al Frank</given>
<surname>Smith</surname>
</name>
</person>
<person id="p6">
<name>
<given>Henry</given>
<surname>Smith</surname>
</name>
<father ref="p5"/>
</person>
</family-tree>
The schema is:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="family-tree">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="person" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="father" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="id" use="required" type="xsd:ID"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="name">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="given"/>
<xsd:element minOccurs="0" name="surname"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="given" type="xsd:string"/>
<xsd:element name="surname" type="xsd:string"/>
<xsd:element name="father">
<xsd:complexType>
<xsd:attribute name="ref" use="required" type="xsd:IDREF"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Which XML parser are you using? Perhaps your parser doesn't like the fact that you have an id that is not referenced anywhere in the document. However, I don't remember reading about such a requirement. Perhaps adding standalone="no" to the XML declaration (<?xml version="1.0" standalone="no"?>) will help?