cancel
Showing results for 
Search instead for 
Did you mean: 

xsd type = QName issue

Former Member
0 Kudos

Hi experts:

Help required on xsd type = QNAME

I'm facing issue in creating the target XML which is to be accepted by a webserver. One of the field is of type xsd:type QName.

XSD:

<xsd:complexType name="ItemList">

<xsd:sequence>

<xsd:element name="Value" minOccurs="0" form="qualified"/>

</xsd:sequence>

<xsd:attribute name="ItemPath" type="xsd:string"/>

<xsd:attribute name="ItemName" type="xsd:string"/>

<xsd:attribute name="ValueTypeQualifier" type="xsd:QName"/>

</xsd:complexType>

In the wsdl for Value there is no type defined.

XML Instance for the above XSD, which is accepted by webserver:

<ItemList>

<Items ValueTypeQualifier="xsd:decimal" ItemPath="SAPPPP1" ItemName="Bucket Brigade.Real4" >

<Value xsi:type="xsd:decimal">123.43</Value>

</Items>

</ItemList>

XML Instance generated by PI

<ItemList>

<Items ValueTypeQualifier="xsd:decimal" ItemPath="SAPPPP1" ItemName="Bucket Brigade.Real4" >

<Value>123.43</Value>

</Items>

PI doesn't create xml with xsi:type="xsd:decimal" for the Value Element. How to get this tag for the Element.

Note: This is not an attribute for Value Element.

Regards

Praveen K.

Accepted Solutions (1)

Accepted Solutions (1)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Praveen Kurni,

Can you please recheck the XML which is expected by web service?

I recommend you to read more about concept called "NameSpace" [Link1|http://www.w3schools.com/xml/xml_namespaces.asp] (search over net).

Note:- In

<Value xsi:type="xsd:decimal">123.43</Value>

'Value' is element. 'type' is attribute. 'xsi' is namespace reference.

Ideally in your case XML expected in your scenatio should be like this

<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Input xmlns:ns0="http://company.com/NameOfNamespacePresentInESR" xml:xsi = "http://someThing.com/something">
  <ItemList>
   <Items ValueTypeQualifier="xsd:decimal" ItemPath="SAPPPP1" ItemName="Bucket Brigade.Real4" >
   <Value xsi:type="xsd:decimal">123.43</Value>
  </Items>
 </ItemList>
</ns0:MT_Input>

Regards,

Raghu_Vamsee

Edited by: Raghu Vamsee on Jan 24, 2011 11:13 PM

Former Member
0 Kudos

Hi Raghu Vamsee,

Your analysis was true. But my issue is with QName xsd Type.

My XML instance will be accepted by webserver only if it got two Namespaces:

1. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

2. xmlns:xsd="http://www.w3.org/2001/XMLSchema"

This I'm well aware and I expected the same from you. This is the reason I didn't mention in my sample xml instance.

Let me explain once again

WSDL doesn't have any type for "Value" Element, check the xsd.

<xsd:sequence>
<xsd:element name="Value" minOccurs="0" form="qualified"/>
</xsd:sequence>

but webserver is accepting the Value and type at runtime by stating the tag "xsi:type="xsd:decimal" as follows:

<ItemList>
<Items ValueTypeQualifier="xsd:decimal" ItemPath="SAPPPP1" ItemName="Bucket Brigade.Real4" >
<Value xsi:type="xsd:decimal">123.43</Value>
</Items>
</ItemList>

Note: neither xsi, nor type are attributes here.

With PI Message Mapping its not possible to generate such tag at runtime. Becasue in PI for source structure you create a Value Element as "xsd:String" to map to the wsdl Value Element which doesn't have any xsd:type declared, but when we map this element it should have the tag xsi:type ="xsd:decimal". in the target then only webserver will accept the xml. With PI Message I'm unable to create the tag.

If I assume either 'type' as attribute, we don't have a 'type' attrubute in wsdl then where do I map it So this is wrong assumption :-).

I tried defining Value Element type as xsd:QName but still it is not generating the above tag after mapping.

I hope this is clear now.

I guess I should try with Java/XSLT Mapping to generate this.

Any one tried with XMLAnonymizerBean module to add this tag, other than adding or deleting namespaces.

Thanks in advance

Regards

Praveen K

Answers (3)

Answers (3)

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Praveen Kurni,

It would be helpful, if you can paste here the 1)WSDL and the 2)XML which is working for web service now.

Regards,

Raghu_Vamsee

stefan_grube
Active Contributor
0 Kudos

> <Value xsi:type="xsd:decimal">123.43</Value>

The graphical mapping tool does not offer a function to add an xsi attribute. So you have to use XSLT or Java mapping to add this attrubute.

I think a Java mapping which interprets the payload as string and adds this attribute with string commands might be more efficient.

Usually a web service does not request the xsi attribute and works anyway, so if your web service does not work without it, it seems to be very special.

Former Member
0 Kudos

Hi Stefen,

Thanks for your response.

I tried all options in adding the xsi:type tag to the Value Element using Graphical mapping. But no luck. As you said it looks me special too because, I could found out that this webserver takes dynamic values at runtime. Its as follows:

When I send

<ns1:Value xsi:type="xsd:decimal">123.23</ns1:Value>, Webserver is accepting it as decimal value.

and

<ns1:Value xsi:type="xsd:double">123.2345555</ns1:Value>, Werbserver is accepting it as double value.

by which I came to know that webserver is accepting any value provided that you specify your xsd type at runtime using the tag.

But when I send

<ns1:Value>123.23</ns1:Value>

If I don't specify any thing then it throws me error "unspecified error".

Its not the namespace what we sent in the xml as <xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> its the xsd type what we specify at runtime along with the Value.

As I said earlier <Value> element in xsd I mean WSDL is not defined with any xsd type.

<xsd:element name="Value" minOccurs="0" form="qualified"/>

While running the webserver we can choose the xsd type for this Value as Decimal / Double / Integer / String. From a client perpective when we request data to to Server we need to send value with its xsd type specified in it. Then only it is accepting.

Please have a look at http://opcda.info/index.php?sel=articles&id=2. or let me know if my understanding is incorrect. I can send the WSDL so that you can get me some input on how to handle this without Java/XSLT mappings.

Regards

Praveen K

stefan_grube
Active Contributor
0 Kudos

> <ns1:Value>123.23</ns1:Value>

> If I don't specify any thing then it throws me error "unspecified error"

You have defined the xsd type already in "ValueTypeQualifier" so the etra declaration of Value is reduntant and should not be necessary, but i know how such discussion alwasy end: Web service guys do not change anything, no matter what you say.

> I can send the WSDL so that you can get me some input on how to handle this without Java/XSLT mappings.

I can't. Sorry.

Former Member
0 Kudos

Hi Stefen,

Thanks for the reply,

Good input to resolve this issue I suppose:

"ValueTypeQualifier". When I send value to this attribute as "xsd:decimal" it throws me error

"xsd:decimal" is not defined for any object // sorry could not remember exact error at this time.

But I guess, If I can add

1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

2. xmlns:xsd="http://www.w3.org/2001/XMLSchema"

in my target xml structure may be it should work.

Regards

Praveen K

stefan_grube
Active Contributor
0 Kudos

> But I guess, If I can add

> 1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

> 2. xmlns:xsd="http://www.w3.org/2001/XMLSchema"

This is of course crucial to add those namespaces, but also not possible with graphical mapping.

Former Member
0 Kudos

Hi Stefen,

Yes initially I was clueless in adding these namespaces in mapping, then found a thread answered by you.

Any suggestions on the above thread please.

stefan_grube
Active Contributor
0 Kudos

In this thread there was no namespace at all. But you want to add different namespaces.

I have seen in the thread, that it is possible to upload a sample XML as target meassge. It has been a long time since I tried this the last time. Maybe it works for you?

Former Member
0 Kudos

Hi Stefen & Raghu,

Many thanks for your support,

I could solve the issue only with Java Mapping.

Message Mapping couldn't help to add the xml name spaces and xsi:type="xsd:decimal" tag to an element.

Regards

Praveen K

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Praveen Kurni,

I understand, as of now your web service is acepting only the below XML.

<ItemList>
 <Items ValueTypeQualifier="xsd:decimal" ItemPath="SAPPPP1" ItemName="Bucket Brigade.Real4" >
 <Value xsi:type="xsd:decimal">123.43</Value>
 </Items>
</ItemList>

First, we both agree that the WSDL (XSD based on WSDL) which is published is not correct, please ask the web service owner to correct it. Then reimport new WSDL.

If it is not possible, please consider below solution as last option.

As XML above is not well-formed ( beacuse : is not allowed in attribute or element name), we can not use Graphical or XSLT mapping.

To archive this, you can first use graphical mapping for transformations (without any attribute to Value) and then followed by below Java Mapping.

package com.mapping;

import java.io.*;
import com.sap.aii.mapping.api.*;

public class SimpleJavaMapping_PI71 extends AbstractTransformation
{
	public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException
	{
		try
		{
			InputStream inputstream = transformationInput.getInputPayload().getInputStream();
			OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();

			byte[] b = new byte[inputstream.available()];
			inputstream.read(b);
			String strOutputContent = new String(b);
			strOutputContent.replaceAll("<Value>", "<Value xsi:type=\"xsd:decimal\">");
			outputstream.write(strOutputContent.getBytes());
		} catch (Exception exception)
		{
			exception.printStackTrace();
		}
	}
}

Regards,

Raghu_Vamsee

Former Member
0 Kudos

Hi Raghu,

I have request the webserver owner, to change the wsdl as follows:

from

<xsd:element name="Value" minOccurs="0" form="qualified" >

to

<xsd:element name="Value" minOccurs="0" form="qualified" type="xsd:decimal"/>

But they said its a standard webservice provided to all customers who are implementing in Automation Industry using (D)COM technology.

I think only Java mapping should solve my problem. I need to try Java mapping program for this issue.

Many thanks for the piece of code.

Please let me know if you have any other alternatives.

Regards

Praveen K