on 07-28-2008 6:32 PM
Hi Guys,
I need to do a HTTP post and the xml has multipart. I thought of using the soap adapter with the followign options as true
1. Do not use soap envelope
2. keep attachments
I want to know which part of the payload i need to message mapping and which part i need to append with the xslt mapping.
any help with the xslt mapping or any other ideas of the acheiving this would be really appreciated.
The xml which i need to post is as below
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>
<Password>YOURPASSWORD</Password></AccessRequest>
<?xml version="1.0" ?>
<AddressValidationRequest xml:lang='en-US'>
<Request>
<TransactionReference>
<CustomerContext /><XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
</Request>
<MaximumListSize>3</MaximumListSize>
<AddressKeyFormat>
<ConsigneeName>UPS Capital</ConsigneeName>
<BuildingName>Business Credit</BuildingName>
<AddressLine>425 Day Hill Road</AddressLine>
<AddressLine>P.O. Box 400</AddressLine>
<AddressLine>Main Office</AddressLine>
<PoliticalDivision2>Windsor</PoliticalDivision2>
<PoliticalDivision1>CT</PoliticalDivision1>
<PostcodePrimaryLow>06095</PostcodePrimaryLow>
<CountryCode>US</CountryCode>
</AddressKeyFormat>
</AddressValidationRequest
Thanks,
Srini
Hello,
I am not 100% sure if you need to send a content-type multipart or if you only mean two root-segments with "multipart". Anyway the solution is similar. I assume the second variant because easier.
1. map your AddressValidationRequest in the normal graphical mapping (this means you create message type and interface for this structure)
2. write an XSLT which takes this AdressValidationRequest as input structure
in this XSLT, you also add some text constants (your AccessRequest structure at the top of the document).
3. you define an interface mapping which first executes the graphical and then the XSLT mapping. For the IM, you define Target interface = AdressValidationRequest interface, although the result will not be of that type at runtime. This is the trick. XI does not validate the result. That means you can create anything as output. But you have to define a target interface for the IM. Because your output is not wellformed XML, you cannot define this structure in XI, or map it in graphical mapping. A bit sick.
4. create normal communication channel HTTP receiver, easier than using SOAP. Your content-type is text/xml ?
About the XSLT. Try the following (not tested this variant, but used similar in other project). Note that these local-name calls are needed because XI creates the ns0-Namespace garbgage, which normally cannot be read by the receiver.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- important to set the output method to html, otherwise transformer would escape, we dont want that.
Because the result will be sent to an HTTP server as HTTP body -->
<xsl:output method="html" encoding="ISO-8859-1"/>
<xsl:template match="*">
<!-- remove element prefix (if any) -->
<xsl:element name="{local-name()}">
<!-- process attributes -->
<xsl:for-each select="@*">
<!-- remove attribute prefix (if any) -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<!-- root template -->
<!-- add multipart header -->
<xsl:template match="/">
<xsl:text>
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>*<Password>YOURPASSWORD</Password>*</AccessRequest>
</xsl:text>
<!-- copy the complete payload -->
<xsl:apply-templates/>
<!-- add multipart footer -->
<xsl:text>
<!-- not applicable for you -->
</xsl:text>
</xsl:template>
</xsl:stylesheet>
CSY
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Christian,
Do you think with this the message will be sent with the two xml tag versions like below. I need to have these 2 xml tags in the message when i send the request.
can you please let me know if this is possible or *do i need to write anything in the xslt mapping to add the second xml declaration tag like <?xml version="1.0" ?>*
<?xml version="1.0" ?>
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>
<Password>YOURPASSWORD</Password>
</AccessRequest>
<?xml version="1.0" ?>
<AddressValidationRequest xml:lang='en-US'>
<Request>
<TransactionReference>
<CustomerContext /><XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
</Request>
<MaximumListSize>3</MaximumListSize>
<AddressKeyFormat>
<ConsigneeName>UPS Capital</ConsigneeName>
<BuildingName>Business Credit</BuildingName>
<AddressLine>425 Day Hill Road</AddressLine>
<AddressLine>P.O. Box 400</AddressLine>
<AddressLine>Main Office</AddressLine>
<PoliticalDivision2>Windsor</PoliticalDivision2>
<PoliticalDivision1>CT</PoliticalDivision1>
<PostcodePrimaryLow>06095</PostcodePrimaryLow>
<CountryCode>US</CountryCode>
</AddressKeyFormat>
</AddressValidationRequest>
any help would be really appreciated
Thanks,
Srini
Hi Christian,
I have created xslt code as below and it is giving errors as
at: file:///c:/DOCUME~1/srinu/Desktop/UPS_new.xsl 19
java.lang.RuntimeException: Error: at AccessRequest on line 19 of file:///c:/DOCUME~1/srinu/Desktop/UPS_new.xsl:
XTSE0010: xsl:text must not contain child elements
XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://Velsol-Integration.stateindustrial.com">
<xsl:output method="html" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="*">
<!-- remove element prefix (if any) -->
<xsl:element name="{local-name()}">
<!-- process attributes -->
<xsl:for-each select="@*">
<!-- remove attribute prefix (if any) -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>EC26E5B354448E54</AccessLicenseNumber>
<UserId>ackschmi</UserId>
<Password>stateups</Password>
</AccessRequest>
</xsl:text>
<xsl:text disable-output-escaping="yes">
<xsl:processing-instruction name="xml" version="1.0">
<?xmlversion = '1.0'?></xsl:processing-instruction>
</xsl:text>
<AddressValidationRequest>-
<Request>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
</Request>
<AddressKeyFormat>
<ConsigneeName>LONG POINT GOLF COURSE</ConsigneeName>
<BuildingName>LONG POINT GOLF COURSE</BuildingName>
<AddressLine>1 OSPREY RD</AddressLine>
<AddressLine>NASSAU</AddressLine>
<PoliticalDivision2>AMELIA CITY</PoliticalDivision2>
<PoliticalDivision1>FL</PoliticalDivision1>
<PostCodePrimaryLow>32034</PostCodePrimaryLow>
<CountryCode>US</CountryCode>
</AddressKeyFormat>
<MaximumListSize>15</MaximumListSize>
</AddressValidationRequest>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
any help would be appreciated
Thanks,
Srini
Hi Mario,
Thanks for the quick reply and now i understand the error. Can you please tell me how to maintain the header and body under this <xsl:text>.
Do i need to write <xsl:text> for every node ?
Header - constant
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>YOURACCESSLICENSENUMBER</AccessLicenseNumber>
<UserId>YOURUSERID</UserId>
<Password>YOURPASSWORD</Password></AccessRequest>
Body
<?xml version="1.0" ?>
<AddressValidationRequest xml:lang='en-US'>
<Request>
<TransactionReference>
<CustomerContext /><XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
</Request>
<MaximumListSize>3</MaximumListSize>
<AddressKeyFormat>
<ConsigneeName>UPS Capital</ConsigneeName>
<BuildingName>Business Credit</BuildingName>
<AddressLine>425 Day Hill Road</AddressLine>
<AddressLine>P.O. Box 400</AddressLine>
<AddressLine>Main Office</AddressLine>
<PoliticalDivision2>Windsor</PoliticalDivision2>
<PoliticalDivision1>CT</PoliticalDivision1>
<PostcodePrimaryLow>06095</PostcodePrimaryLow>
<CountryCode>US</CountryCode>
</AddressKeyFormat>
</AddressValidationRequest
any help would be really appreciated
Thanks,
Srini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For XSLT Mapping guide:
http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/frameset.htm
Thanks,
Boopathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi srinivas
check the below blog
XSLT mapping for multiple segments of XML
generic xslt mapping part 1
generic xslt mapping part 2
Step u2013 By u2013 Step Simple Approach for XSLT Mapping
regards
kummari
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.