在 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>
...
有什么帮助吗?
谢谢
编辑
源模式
基本上是一个 SMS 列表(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 服务自动生成的
Recipients 是我想从 phonenumber 字符串创建的字符串数组,因为我每条消息只有一个收件人
...
<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>