on 03-19-2008 3:49 AM
Hi all,
This is the response which I get from the Webservice which I'm calling using the SAOP adapter
How can I remove xmlns="" from the sc and sm tags?
Input:
<Response xmlns="urn:com.xyz.xyz/platform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error>
<sc xmlns="">100</sc>
<sm xmlns="">No Organizations found</sm>
</error>
</Response>
Expected Output structure:
<Response xmlns="urn:com.xyz.xyz/platform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error>
<sc>100</sc>
<sm>No Organizations found</sm>
</error>
</Response>
Thanks,
Srini
Is ur mapping failing in this case? What is the problem u r facing with the current response?
Still if u want to edit it, u have to write a java mapping code, wherein u may pass the complete xml and using dom parsing remove the nodes.
Regards,
Prateek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Prateek,
I'm mapping this into MT_Response which is not getting the data because of that xmlns="", so mapping is failing.
How should the UDF be?
I tried using XMLAnonymizerBean but still not working:
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/5767] [original link is broken] [original link is broken] [original link is broken];
This should be no problem in mapping.
Have a build the interface in Integration Repository, or did you upload it as external definition?
If you build it in Repository, the mapping does not work due to the missing namespace prefix of the response:
<Response xmlns="urn:com.xyz.xyz/platform"> instead of
<n0:Response n0:xmlns="urn:com.xyz.xyz/platform">
You could do following:
- upload the WSDL from the web service as external definition and build your mapping based on this
- use the XMLAnonymizerBean to remove all namespaces and remove also the XML Namespace from the Message Type.
Regards
Stefan
Stefan,
I have uploaded it as an external definition, the structure which they have for the Response wsdl is not same as the structure which they are send as response.
Thats the reason I need to remove xmlns="" , I have tried using XMLAnonymizerBean and followed the note Note 880173 Example 2.
My problem is similar to that example.
This should be no problem in mapping.
Have a build the interface in Integration Repository, or did you upload it as external definition?
If you build it in Repository, the mapping does not work due to the missing namespace prefix of the response:
<Response xmlns="urn:com.xyz.xyz/platform"> instead of
<n0:Response n0:xmlns="urn:com.xyz.xyz/platform">
You could do following:
upload the WSDL from the web service as external definition and build your mapping based on this
use the XMLAnonymizerBean to remove all namespaces and remove also the XML Namespace from the Message Type.
Stefan,
Even I looked into Srini's issue. The problem seems to be an extra attribute in his element xmlns="" . When we remove the xmlns in the test tab and do the test , it's working fine. Yesterday we were trying to apply XMLAnonymizerBean Module, but it's throwing error - com.sap.aii.api.delivery exception.
Do we need to add the module as the last parameter , right? (In Receiver SOAP Adapter)
raj.
You cannot use XMLAnonymizerBean Module for this. The bean can only remove namespaces, but not add them.
The xmlns="" removes the namespace for this element.
See: This XML
<Response xmlns="urn:com.xyz.xyz/platform">
<error>
<sc xmlns="">100</sc>
<sm xmlns="">No Organizations found</sm>
</error>
</Response>
is the same as this:
<ns0:Response xmlns:ns0="urn:com.xyz.xyz/platform">
<ns0:error>
<sc>100</sc>
<sm>No Organizations found</sm>
</ns0:error>
</ns0:Response>
When you have a WSDL as external definition, and the response message is not valid according to this definition, then you should alter the WSDL. That is easier as doing anything to change the message during runtime.
Otherwise you have to write a Java-mapping or Adapter Module for this case.
Regards
Stefan
You can edit the WSDL with a tool like XMLSpy, but the first approach should be to convince the provider of the web service to provide a WSDL which defines the interface correctly or change the receiving message.
On the other side you can try to use the Java mapping which was posted by Vijayanand Poreddy.
But in my opinion the error should always fixed at the place where the error is. And according to your description the error comesfrom the receiver.
Regards
Stefan
The Webservices guys are making the changes in there wsdl, the problem is other tools seams to be ignoring the xmlns="" attribute but not XI. That the reason they couldn't see that problem, will update after loading fresh wsdl.
Thanks guys for the rply's helped a lot, I'm not closing this thread yet.
Hi Srinivas,
Using Java mapping you can remove or add whatever the content to the XML message. Below is the code i am giving. Create a Jar file and upload into XI. This code you can test using SAP NWDS also. Put your XML message in C:\test\in.xml file and run it. you can check the desired output in out.xml.
package com.sap.wrap;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.AbstractTrace;
import java.util.Map;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
public class truncate_namespace implements StreamTransformation {
public static void main(String[] args) {
try {
InputStream in = new FileInputStream(new File("in.xml"));
OutputStream out = new FileOutputStream(new File("output.xml"));
truncate_namespace myMapping = new truncate_namespace();
myMapping.execute(in, out);
} catch (Exception e) {
e.printStackTrace();
}
}
String strXML = new String();
int index = 0;
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param) {
this.param = param;
}
public void execute(InputStream in, OutputStream out) {
int strBegin, strEnd;
String ns1String = new String();
String headerString = new String();
String outString = new String();
try {
//Convert InputStream to String
OutputStream temp = new ByteArrayOutputStream(1024);
byte[] buffer = new byte[1024];
for (int read = in.read(buffer); read > 0; read = in.read(buffer))
temp.write(buffer, 0, read);
strXML = temp.toString();
strXML = strXML.replaceAll(" xmlns=\"\">", ">");
outString = strXML;
out.write(outString.getBytes());
} catch (Exception e) {
}
}
}
Thanks & Regards
Vijayanand Poreddy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.