Biztalk 映射,从字符串创建 string[]
在 biztalk 映射中,源模式有一个字符串,目标模式正在等待字符串数组。
我只需要创建一个只有一个字符串的字符串数组,但我做不到。
我尝试使用脚本 functoid 和一些内联 C#:
public Array ArrayBuilder(string param1)
{
ArrayList result = new ArrayList();
result.Add(param1);
return result.ToArray(typeof( string ));
}
但 functoid 输出不是数组,而是:
...
<recipients>System.String[]</recipients>
...
有帮助吗?
谢谢
编辑
源模式
基本上是短信列表(ID、消息和电话号码)。通过编排中的循环,我迭代所有 SMS 并准备一条 SMSSend 消息。列表中的每条短信都会发生此映射(这就是为什么我有一个计数器)
电话号码是我遇到问题的字符串
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/ADOSybaseWCFServices" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/ADOSybaseWCFServices" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="SMSBatch">
<xs:sequence>
<xs:element name="IDBatch" type="xs:int" />
<xs:element name="SMSList" nillable="true" type="tns:ArrayOfSMS" />
</xs:sequence>
</xs:complexType>
<xs:element name="SMSBatch" nillable="true" type="tns:SMSBatch" />
<xs:complexType name="ArrayOfSMS">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="SMS" nillable="true" type="tns:SMS" />
</xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfSMS" nillable="true" type="tns:ArrayOfSMS" />
<xs:complexType name="SMS">
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Message" nillable="true" type="xs:string" />
<xs:element name="PhoneNumber" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="SMS" nillable="true" type="tns:SMS" />
柜台:
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://SendSMS.counterSchema" targetNamespace="http://SendSMS.counterSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element default="0" name="counter" type="xs:int" />
目标架构
为了您的理智,我不会放置整个架构,它是从 WCF 服务自动生成的
收件人是我想要从电话号码字符串创建的字符串数组,因为每条消息只有一个收件人
...
<xml>
<complexType name="ArrayOf_soapenc_string">
<complexContent mixed="false">
<restriction xmlns:q1="http://schemas.xmlsoap.org/soap/encoding/" base="q1:Array">
<attribute xmlns:d5p1="http://schemas.xmlsoap.org/wsdl/" d5p1:arrayType="q1:string[]" ref="q1:arrayType" />
</restriction>
</complexContent>
</complexType>
<complexType name="Submission" abstract="true">
<sequence>
<element xmlns:q2="http://mobicomp.com/smsexpress/webservice/server/message" name="contactLists" nillable="true" type="q2:ArrayOf_soapenc_string" />
<element name="deliveryDate" nillable="true" type="dateTime" />
<element name="notification" type="boolean" />
<element xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/" name="notificationRecipient" nillable="true" type="q3:string" />
<element xmlns:q4="http://schemas.xmlsoap.org/soap/encoding/" name="notificationType" nillable="true" type="q4:string" />
<element xmlns:q5="http://mobicomp.com/smsexpress/webservice/server/message" name="recipients" nillable="true" type="q5:ArrayOf_soapenc_string" />
<element xmlns:q6="http://schemas.xmlsoap.org/soap/encoding/" name="sender" nillable="true" type="q6:string" />
<element name="validity" type="int" />
</sequence>
</complexType>
</xml>
...
已解决:
我使用了带有内联 XSLT 模板的脚本 functoid
<xsl:template name="recipients">
<xsl:param name="phone" />
<recipients>
<recipient><xsl:value-of select="$phone" /></recipient>
</recipients>
In a biztalk map, the source schema has a string and the destination schema is waiting for a array of strings.
I just need to create a string array with just one string but I can't make it.
I tried with a scripting functoid and some inline C#:
public Array ArrayBuilder(string param1)
{
ArrayList result = new ArrayList();
result.Add(param1);
return result.ToArray(typeof( string ));
}
But instead of an array, the functoid outputs:
...
<recipients>System.String[]</recipients>
...
Any help?
thanks
EDIT
SOURCE SCHEMAS
Basically a list of SMS (Id, message and phone number). With a loop in the orchrestation I iterate through all the SMS and prepare a SMSSend message. this mapping will happen for each of the SMS in the list (that why I have a counter)
Phone number is the string Im having the issue
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/ADOSybaseWCFServices" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/ADOSybaseWCFServices" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="SMSBatch">
<xs:sequence>
<xs:element name="IDBatch" type="xs:int" />
<xs:element name="SMSList" nillable="true" type="tns:ArrayOfSMS" />
</xs:sequence>
</xs:complexType>
<xs:element name="SMSBatch" nillable="true" type="tns:SMSBatch" />
<xs:complexType name="ArrayOfSMS">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="SMS" nillable="true" type="tns:SMS" />
</xs:sequence>
</xs:complexType>
<xs:element name="ArrayOfSMS" nillable="true" type="tns:ArrayOfSMS" />
<xs:complexType name="SMS">
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Message" nillable="true" type="xs:string" />
<xs:element name="PhoneNumber" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="SMS" nillable="true" type="tns:SMS" />
Counter:
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://SendSMS.counterSchema" targetNamespace="http://SendSMS.counterSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element default="0" name="counter" type="xs:int" />
DESTINATION SCHEMA
For your sanity, I won't put the whole schema, it is autogenerated from a WCF service
Recipients is the string array I want to create from the phonenumber string, since I just have one recipient per message
...
<xml>
<complexType name="ArrayOf_soapenc_string">
<complexContent mixed="false">
<restriction xmlns:q1="http://schemas.xmlsoap.org/soap/encoding/" base="q1:Array">
<attribute xmlns:d5p1="http://schemas.xmlsoap.org/wsdl/" d5p1:arrayType="q1:string[]" ref="q1:arrayType" />
</restriction>
</complexContent>
</complexType>
<complexType name="Submission" abstract="true">
<sequence>
<element xmlns:q2="http://mobicomp.com/smsexpress/webservice/server/message" name="contactLists" nillable="true" type="q2:ArrayOf_soapenc_string" />
<element name="deliveryDate" nillable="true" type="dateTime" />
<element name="notification" type="boolean" />
<element xmlns:q3="http://schemas.xmlsoap.org/soap/encoding/" name="notificationRecipient" nillable="true" type="q3:string" />
<element xmlns:q4="http://schemas.xmlsoap.org/soap/encoding/" name="notificationType" nillable="true" type="q4:string" />
<element xmlns:q5="http://mobicomp.com/smsexpress/webservice/server/message" name="recipients" nillable="true" type="q5:ArrayOf_soapenc_string" />
<element xmlns:q6="http://schemas.xmlsoap.org/soap/encoding/" name="sender" nillable="true" type="q6:string" />
<element name="validity" type="int" />
</sequence>
</complexType>
</xml>
...
SOLVED:
I used and Scripting functoid with Inline XSLT Template
<xsl:template name="recipients">
<xsl:param name="phone" />
<recipients>
<recipient><xsl:value-of select="$phone" /></recipient>
</recipients>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您考虑使用 XSLT 模板来处理通过您的方法提取的各个字符串值。
因此,您创建数组并为每个字符串生成目标 Xml。
看看此链接讨论了在地图中使用 XSLT 模板。
如果没有目标架构,这就是我目前所能建议的。
华泰
I would suggest that you look into using an XSLT template for the individual string values extracted by your method.
So, you create your array and for each string, go off and generate the destination Xml.
Take a look at This Link which talks about using XSLT templates in your map.
Without the destination schema, that's all I can suggest at the moment.
HTH
好吧,根据您实际上应该发送到目标地图的内容,我可能会这样做:
假设您收到一个字符串
flibberdyjibit
并希望使其成为 < 中的唯一项目code>string[] 我会这样做:如果您收到某种需要转换为数组的分隔字符串(我将假设为管道),您会执行以下操作:
注意:我还没有编译过其中任何一个,并且可能存在语法错误,但如果有的话,智能感知应该可以帮助您。
Well, depending on what you're actually supposed to be sending to the destination map, I would probably do something like this:
Assuming you receive a string
flibberdyjibit
and want to make it the only item in astring[]
I'd do:If you're receiving some kind of delimited string that you need to turn into an array (I'm going to assume Pipes) you'd do something like:
NOTE: I have not compiled either of these, and there may be syntax errors, but intellisense should help you out there, if there are.