Biztalk 映射,从字符串创建 string[]

发布于 2024-12-12 03:03:43 字数 4216 浏览 0 评论 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>
...

有帮助吗?

谢谢

编辑

源模式

基本上是短信列表(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半世晨晓 2024-12-19 03:03:43

我建议您考虑使用 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

深海夜未眠 2024-12-19 03:03:43

好吧,根据您实际上应该发送到目标地图的内容,我可能会这样做:

假设您收到一个字符串 flibberdyjibit 并希望使其成为 < 中的唯一项目code>string[] 我会这样做:

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

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

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

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

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 a string[] I'd do:

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

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:

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

NOTE: I have not compiled either of these, and there may be syntax errors, but intellisense should help you out there, if there are.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文