0

在 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>

4

2 回答 2

0

好吧,根据您实际应该发送到目标地图的内容,我可能会执行以下操作:

假设您收到一个字符串flibberdyjibit并想让它成为string[]我要做的唯一项目:

public string[] ReturnStringArray(string input)
{
    string[] output = new string[] { input };
    return output;
}

如果您收到某种需要将其转换为数组的分隔字符串(我将假设为 Pipes),您将执行以下操作:

public string[] ReturnStringArray(string input)
{
    return input.split('|');
}

注意:我没有编译其中任何一个,并且可能存在语法错误,但如果有的话,intellisense 应该可以帮助您。

于 2011-10-25T13:26:29.727 回答
0

我建议您考虑为您的方法提取的单个字符串值使用 XSLT 模板。

因此,您创建数组并为每个字符串生成目标 Xml。

看看这个链接,它讨论了在你的地图中使用 XSLT 模板。

如果没有目标模式,这就是我目前所能建议的。高温高压

于 2011-10-25T13:37:39.850 回答