I have a scheme that looks like
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RequestResponseBase" type="RequestResponseBase" />
<xs:complexType name="RequestResponseBase">
<xs:sequence>
<xs:element name="Parameters"
type="Parameters">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Parameters">
<xs:sequence>
<xs:element minOccurs="0"
maxOccurs="unbounded"
name="Parameter"
type="Parameter">
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Parameter">
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Value" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
I want to create datacontracts for the types so I've defined the following classes
public class RequestResponseBase
{
public Parameters Parameters { get; set; }
}
public class Parameters
{
public Parameter[] Parameter { get; set; }
}
But when I run the service and create a request with soapUI it suggests me to fill the following request:
<tem:RequestResponseBase>
<wcf:Parameters>
<wcf:Parameter>
<wcf:Parameter>
<wcf:Name>gero et</wcf:Name>
<wcf:Value>sonoras imperio</wcf:Value>
</wcf:Parameter>
</wcf:Parameter>
</wcf:Parameters>
</tem:RequestResponseBase>
Why Parameter element is wrapped with another Parameter element and how to avoid that?!
What if you change your code to:
public class RequestResponseBase
{
public Parameter[] Parameters { get; set; }
}
Related
I have a WSDL . Following WSDL i am trying to try in SoapUI
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" name="NextGenService" targetNamespace="">
<wsp:Policy wsu:Id="DocumentExchangePort_policy">...</wsp:Policy>
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/Message" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/Message">
<xs:simpleType name="StreamBody">
<xs:restriction base="xs:base64Binary"/>
</xs:simpleType>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:import namespace="http://schemas.microsoft.com/Message"/>
<xs:import namespace="http://schemas.datacontract.org/2004/07/SupportingDocsFacade"/>
<xs:element name="RemoteFileInfo">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="http://schemas.microsoft.com/Message" name="FileByteStream" type="q1:StreamBody"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element xmlns:q2="http://schemas.datacontract.org/2004/07/SupportingDocsFacade" name="dcExhange" nillable="true" type="q2:DocumentExchangeRequests"/>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
<xs:element name="byte" nillable="true" type="xs:byte"/>
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
<xs:element name="double" nillable="true" type="xs:double"/>
<xs:element name="float" nillable="true" type="xs:float"/>
<xs:element name="int" nillable="true" type="xs:int"/>
<xs:element name="long" nillable="true" type="xs:long"/>
<xs:element name="QName" nillable="true" type="xs:QName"/>
<xs:element name="short" nillable="true" type="xs:short"/>
<xs:element name="string" nillable="true" type="xs:string"/>
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
<xs:element name="char" nillable="true" type="tns:char"/>
<xs:simpleType name="char">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration"/>
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid"/>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName"/>
<xs:attribute name="Id" type="xs:ID"/>
<xs:attribute name="Ref" type="xs:IDREF"/>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/SupportingDocsFacade" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/SupportingDocsFacade">
<xs:complexType name="DocumentExchangeRequests">
<xs:sequence>
<xs:element name="_documentDescription" nillable="true" type="tns:DescriptionSet"/>
<xs:element name="_loanIdentifier" nillable="true" type="tns:LoanFileIdentifier"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DocumentExchangeRequests" nillable="true" type="tns:DocumentExchangeRequests"/>
<xs:complexType name="DescriptionSet">
<xs:sequence>
<xs:element name="_documentType" nillable="true" type="xs:string"/>
<xs:element name="_x003C_ByteCount_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_DocumentCreated_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_DocumentDescrption_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_DocumentID_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_PageCount_x003E_k__BackingField" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DescriptionSet" nillable="true" type="tns:DescriptionSet"/>
<xs:complexType name="LoanFileIdentifier">
<xs:sequence>
<xs:element name="_x003C_ApplyOnlineID_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_BrokerID_x003E_k__BackingField" nillable="true" type="xs:string"/>
<xs:element name="_x003C_DocumentID_x003E_k__BackingField" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="LoanFileIdentifier" nillable="true" type="tns:LoanFileIdentifier"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="RemoteFileInfo">
<wsdl:part name="parameters" element="RemoteFileInfo"/>
</wsdl:message>
<wsdl:message name="RemoteFileInfo_Headers">
<wsdl:part name="dcExhange" element="dcExhange"/>
</wsdl:message>
<wsdl:message name="INextGenService_UploadDocNextGen_OutputMessage"/>
<wsdl:portType name="INextGenService">
<wsdl:operation name="UploadDocNextGen">
<wsdl:input wsaw:Action="urn:INextGenService/UploadDocNextGen" name="RemoteFileInfo" message="RemoteFileInfo"/>
<wsdl:output wsaw:Action="urn:INextGenService/UploadDocNextGenResponse" message="INextGenService_UploadDocNextGen_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DocumentExchangePort" type="INextGenService">
<wsp:PolicyReference URI="#DocumentExchangePort_policy"/>
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="UploadDocNextGen">
<soap12:operation soapAction="urn:INextGenService/UploadDocNextGen" style="document"/>
<wsdl:input name="RemoteFileInfo">
<soap12:header message="RemoteFileInfo_Headers" part="dcExhange" use="literal"/>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NextGenService">
<wsdl:port name="DocumentExchangePort" binding="DocumentExchangePort">
<soap12:address location="https://l24-a0845.latrobe.biz/SupportingDocsFacade/NextGenService.svc/UploadDoc"/>
<wsa10:EndpointReference>
<wsa10:Address>
https://l24-a0845.latrobe.biz/SupportingDocsFacade/NextGenService.svc/UploadDoc
</wsa10:Address>
</wsa10:EndpointReference>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The webconfig in server to generate the following looks like this
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WsBinding" messageEncoding="Mtom" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" transactionFlow="false" textEncoding="utf-8" >
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="NextGenServiceBehavior" name="SupportingDocsFacade.NextGenService">
<endpoint address="/UploadDoc" binding="wsHttpBinding" bindingConfiguration="WsBinding" name="Basic" contract="SupportingDocsFacade.INextGenService" />
</service>
</services>
<behavior name="NextGenServiceBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
I wrote a client and is it is able to communicate with the service .
The issue came when i tried importing WSDL in SOAP UI
Following is the RemoteFileInfo class used for WCF service
public class RemoteFileInfo : IDisposable
{
[MessageHeader(MustUnderstand = true)]
public DocumentExchangeRequests dcExhange;
[MessageBodyMember]
public Stream FileByteStream;
public void Dispose()
{
if (FileByteStream != null)
{
FileByteStream.Close();
FileByteStream = null;
}
}
}
[Serializable]
[MessageContract]
public class DocumentExchangeRequests
{
private DescriptionSet _documentDescription = null;
private LoanFileIdentifier _loanIdentifier = null;
[DataMember(IsRequired = true)]
public DescriptionSet DocumentDescriptionset
{
get { return _documentDescription = this.DocumentDescriptionset; }
set { this.DocumentDescriptionset = value; }
}
[DataMember(IsRequired = true)]
public LoanFileIdentifier LoanIdentifier
{
get { return _loanIdentifier = this.LoanIdentifier; }
set { this.LoanIdentifier = value; }
}
}
[Serializable]
[MessageContract]
public class DescriptionSet
{
private string _documentType = "";
[DataMember(IsRequired = true)]
public string DocumentTypes
{
get { return _documentType = this.DocumentTypes; }
set { this.DocumentTypes = value; }
}
[DataMember(IsRequired = true)]
public string DocumentID { get; set; }
[DataMember(IsRequired = true)]
public string ByteCount { get; set; }
[DataMember(IsRequired = true)]
public string DocumentCreated { get; set; }
[DataMember(IsRequired = true)]
public string PageCount { get; set; }
[DataMember(IsRequired = true)]
public string DocumentDescrption { get; set; }
}
[Serializable]
[MessageContract]
public class LoanFileIdentifier
{
[DataMember(IsRequired = true, Order = 0, Name = "DocHeaderID")]
public string DocumentID { get; set; }
[DataMember(IsRequired = true, Order = 1, Name = "BrokerID")]
public string BrokerID { get; set; }
[DataMember(IsRequired = true, Order = 2, Name = "ApplyOnlineID")]
public string ApplyOnlineID { get; set; }
}
Any pointer on what is causing the issue . I have been cracking head over this for a week . Is this anything to do with the setting in soapUI or my WSDL itself is wrong ?
WSDL, web service description language, this file doesn’t contain data contract of the service, only XSD files contain the Data Contracts and WSDL has import directives for those XSD files.
Due to this dependency on other files, processing such these WSDL files by some third-party was impossible. Therefore WCF4.5 publish the service metadata by using a Single file. all WSDL information is returned in one single document including some other information.
In SOAPUI, we could use the SingleWSDL file to generate the project.
http://10.157.13.69:1100/Service1.svc?singleWsdl
The premise is that we enable metadata publishing via the Http or Https protocol.
Here is a helpful link, wish it is useful to you.
http://blogs.microsoft.co.il/idof/2011/09/17/whats-new-in-wcf-45-a-single-wsdl-file/
Feel free to let me know if there is anything I can help with.
[com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 1; unexpected element (uri:"http://service.example.com/", local:"custDetails"). Expected elements are <{http://schemas.xmlsoap.org/soap/envelope/}Body>,<{}Customer>,<{http://schemas.xmlsoap.org/soap/envelope/}Envelope>,<{http://schemas.xmlsoap.org/soap/envelope/}Fault>,<{http://schemas.xmlsoap.org/soap/envelope/}Header>]
Problem statement: Camel is not expecting to receive the custDetails (webmethod) and the namespace.
Expectation : to use camel-soap to unmarshal the payload to soapJaxb out of the box.
Generated JAXB classes using maven-jaxb2-plugin for the xsd below. Results produced three classes with annotations - Customer.java, ObjectFactory,java , Order.java.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
>
<xs:element name="Customer">
<xs:complexType >
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="Address" type="xs:string"/>
<xs:element name="ListOfOrders" type="order" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="order">
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="ProductName" type="xs:string"/>
<xs:element name="ListOfDevice" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="DeviceName" type="xs:string"/>
<xs:element name="ManufactureDate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Expose webservice custDetails(..) as follows using cxf endpoint with DataFormat set to PAYLOAD. [UPDATED with #Configuration]
#Configuration
public class WebServiceConfig {
#Autowired
private Bus bus;
#Bean
public CxfEndpoint getCustomerDetails() {
CxfEndpoint cxfEndpoint = new CxfEndpoint();
cxfEndpoint.setAddress("/customerProvide");
cxfEndpoint.setServiceClass(CustomerSvc.class);
cxfEndpoint.setBus(bus);
cxfEndpoint.setDataFormat(DataFormat.PAYLOAD);return cxfEndpoint ;}
#Webservice
public interface CustomerSvc {
#WebMethod
Customer custDetails ( #WebParam(name="Customer")Customer Customer ) ;}
// Simple route in Route class.
#Component
public class CustomerRoute extends RouteBuilder {
public void configure (){
SoapJaxbDataFormat soapDF
= new SoapJaxbDataFormat("com.example.service", new TypeNameStrategy());
from("cxf:bean:getCustomerDetails").unmarshal(soapDF)
.log("receive : ${body}")
}
Wsdl generated and imported to soapUI. sample SOAPUI request to test is as follows.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="http://service.example.com/">
<soapenv:Header/>
<soapenv:Body>
<ser:custDetails>
<ser:Customer>
<Id>1-abc</Id>
<Address>23 Sydney Oxley road</Address>
<ListOfOrders>
<Id>P1344</Id>
<ProductName>DRAM</ProductName>
<ListOfDevice>
<DeviceName>20nm</DeviceName>
<ManufactureDate>15-8-2017</ManufactureDate>
</ListOfDevice>
</ListOfOrders>
</ser:Customer>
</ser:custDetails>
</soapenv:Body>
</soapenv:Envelope>
When I try to unmarshal PAYLOAD with soap dataformat, camel is throwing an error. It is the hitting namespace error. I am not sure why package-info class is not generated. Any help is greatly appreciated. Thank you.
UPDATE, wsdl given below.
<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.example.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="CustomerSvcService" targetNamespace="http://service.example.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.example.com/" attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://service.example.com/">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="Address" type="xs:string"/>
<xs:element minOccurs="0" name="ListOfOrders" type="tns:order"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="order">
<xs:sequence>
<xs:element name="Id" type="xs:string"/>
<xs:element name="ProductName" type="xs:string"/>
<xs:element minOccurs="0" name="ListOfDevice">
<xs:complexType>
<xs:sequence>
<xs:element name="DeviceName" type="xs:string"/>
<xs:element name="ManufactureDate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="custDetails" type="tns:custDetails"/>
<xs:complexType name="custDetails">
<xs:sequence>
<xs:element minOccurs="0" ref="tns:Customer"/>
</xs:sequence>
</xs:complexType>
<xs:element name="custDetailsResponse" type="tns:custDetailsResponse"/>
<xs:complexType name="custDetailsResponse">
<xs:sequence>
<xs:element minOccurs="0" ref="tns:Customer"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="custDetails">
<wsdl:part element="tns:custDetails" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="custDetailsResponse">
<wsdl:part element="tns:custDetailsResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="CustomerSvc">
<wsdl:operation name="custDetails">
<wsdl:input message="tns:custDetails" name="custDetails">
</wsdl:input>
<wsdl:output message="tns:custDetailsResponse" name="custDetailsResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CustomerSvcServiceSoapBinding" type="tns:CustomerSvc">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="custDetails">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="custDetails">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="custDetailsResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CustomerSvcService">
<wsdl:port binding="tns:CustomerSvcServiceSoapBinding" name="CustomerSvcPort">
<soap:address location="http://localhost:12000/services/customerProvide"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
EDIT due to updated question
You try to unmarshal the request payload with Jax-B based on the XML schema you posted at the top of your question.
But in this schema the element custDetails does not exist. It exists in the schema part of your WSDL, but not in the schema?!? Therefore the error unexpected element.
Under Microsoft BizTalk 2009, we want to test the ReceivePipeline(which has a Flat file disassembler) with the built-in TestableReceivePipeline class.
It works fine if we use one single Schema, but it throws an error (System.Xml.Schema.XmlSchemaException: The 'ABC' element is not declared.) when we try to use a schema(Schema1) which has an imported schema(Schema2) inside.
Why I'm getting this error?
code for testing pipeline:
StringCollection documents = new StringCollection();
documents.Add(#"c:\Test.dat");
StringCollection parts = new StringCollection();
Dictionary<string, string> schemas = new Dictionary<string, string>();
schemas.Add("MyCompany.Schema2", #"C:\Schema2.xsd");
schemas.Add("MyCompany.Schema1", #"C:\Schema1.xsd");
Microsoft.BizTalk.TestTools.Pipeline.TestableReceivePipeline pipeline = new MyReceivePipeline();
pipeline.TestPipeline(documents, parts, schemas);
Schema1.xsd source:
<xs:import schemaLocation=".\Schema2.xsd" namespace="http://MyCompany.Schema2" />
<xs:element name="Schema1">
<xs:complexType>
<xs:sequence>
<xs:element name="Header">
<xs:complexType>
<xs:sequence>
<xs:element name="ClientRef" type="xs:string">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="1" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="ns1:Data" />
<xs:element name="Tail">
<xs:complexType>
<xs:sequence>
<xs:element name="RecordCount" type="xs:int">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Schema2.xsd source:
<xs:element name="Data">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" nillable="true">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" wrap_char_type="default" sequence_number="2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="Surname" type="xs:string" nillable="true">
<xs:annotation>
<xs:appinfo>
<b:fieldInfo justification="left" sequence_number="3" wrap_char_type="default" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" />
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
AFAIK this is currently not supported in BizTalk 2009.
In my XML schema I have an element being referenced tens of times by other elements but with different enumerated values for one of its attribute.
For now, instead of creating this element in global space and referencing it later, I am creating a new instance wherever it is needed. This approach has increased my schema size enormously because of repeated creation of almost same element many times. It also may have adverse effect on efficiency of the schema.
The only way that I see is to create element once and then reference it many times but my problem is: one of the attribute of this referenced element is required to have a different set of enumerations for each referencing element.
My question is:
Is it possible to to add an attribute to a "Referenced Element" in XML Schema?
Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myDomain.com" xmlns="http://www.myDomain.com" elementFormDefault="qualified">
<xs:simpleType name="myValues1">
<xs:restriction base="xs:string">
<xs:enumeration value="value1" />
<xs:enumeration value="value2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="myElement">
<xs:complexType mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element ref="myElement">
<xs:complexType>
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mainAtt1" />
</xs:complexType>
</xs:element>
</xs:schema>
Or can we change type of an existing attribute of a "Referenced Element" in XML Schema?
something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.myDomain.com" xmlns="http://www.myDomain.com" elementFormDefault="qualified">
<xs:simpleType name="myValues1">
<xs:restriction base="xs:string">
<xs:enumeration value="value1" />
<xs:enumeration value="value2" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="myValues2">
<xs:restriction base="xs:string">
<xs:enumeration value="value3" />
<xs:enumeration value="value4" />
</xs:restriction>
</xs:simpleType>
<xs:element name="myElement">
<xs:complexType mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
</xs:element>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element ref="myElement">
<xs:complexType>
<xs:attribute name="myAtt" type="myValues2" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="mainAtt1" />
</xs:complexType>
</xs:element>
</xs:schema>
You cannot override the content model of a referenced element. The point of the reference is that it points to exactly the same element every time.
If you really want the element to have different content, you are better off defining multiple global complex types and using them, rather than using an element reference:
<xs:complexType name="Type1" mixed="true">
<xs:attribute name="attr1" type="xs:string" />
<xs:attribute name="attr2" type="xs:string" />
<xs:attribute name="myAtt" type="myValues1" />
</xs:complexType>
<xs:complexType name="Type2" mixed="true">
<xs:complexContent>
<xs:extension base="Type1">
<xs:attribute name="myAtt2" type="myValues2" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="MainElement1">
<xs:complexType>
<xs:sequence>
<xs:element name="myElement" type="Type1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
I would not worry too much about performance. The reference to the global types will be resolved only once at schema load time.
I need to consume a Biztalk service that contains some composite operations. Essentially, one of my entities is in the form
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://HRMApplication.Schemas.Customer" targetNamespace="http://HRMApplication.Schemas.Customer" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="CustomerCode" type="xs:string" />
<xs:element name="Name" type="xs:string" />
<xs:element name="Active" type="xs:int" />
<xs:element name="SubNumber" type="xs:string" />
<xs:element name="CustomerAccountNumber" type="xs:string" />
<xs:element name="AccountBranchCode" type="xs:string" />
<xs:element name="BranchLocationCode" type="xs:string" />
<xs:element name="Attention" type="xs:string" />
<xs:element minOccurs="0" maxOccurs="unbounded" name="Addresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Street1" type="xs:string" />
<xs:element name="Street2" type="xs:string" />
<xs:element name="City" type="xs:string" />
<xs:element name="State" type="xs:string" />
<xs:element name="Zip" type="xs:string" />
<xs:element name="Country" type="xs:string" />
<xs:element name="Description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="unbounded" name="PhoneNumbers">
<xs:complexType>
<xs:sequence>
<xs:element name="PhoneNumber" type="xs:string" />
<xs:element name="PhoneType" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
On the client side, I need to create a proxy for my service, and then create requests passing in customer objects and then displaying the response from the server in c#. How do I go about doing this in code please? Essentially, I am looking for code sample to help start me off of how to handle this sort of scenario given that when I generate a proxy using the ADD SERVICE REFERENCE option in visual studio, I get a proxy that requires I create a request object and then expect a response object.
Even within BizTalk, your composite operation will be wrapped around the response object. Your customer element will probably be created within the response object. The response object name and namespace is usually defined in the Adapter. What type of adapter are you using?