Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Declare array in "Message assignment"
- This topic has 20 replies, 1 voice, and was last updated 9 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
June 30, 2008 at 6:56 AM #20022
I am calling a webservice that has a parameter that it takes int[]
How can I declare an array in a message assignment and add declared array
from a schemad valua that has been distinguished promoted and the value is
Data type int.I cant even declare a array in a “Message assignment” using this code
System.Int32[] id = { 71486};But I can declare this is in Windows application
Anyone please help me
-
June 30, 2008 at 7:10 AM #20023
You need to generate a schema to represent the web service data format. You won’t need to declare a .CLR type array because the array will be represented in XML. If you are on R2, you can use a WCF adapter and the WCF service consuming wizard (the service does not need to be a WCF service). Here is a link: http://msdn.microsoft.com/en-us/library/bb226552.aspx If you don’t have R2, then you should use the SOAP or WSE adapter. Both of these adapters have schema generation wizards as well.
-
June 30, 2008 at 7:52 AM #20024
I want to call the webservice like this by assigning the value from a message assignment and with value that comes in from the xml data.
Msg_Request.DebiteringsunderlagsId = Msg_Teledatabasen_XML.DebiteringsunderlagsId; <– error “cannot implicity convert type ‘System.Int32’ to ‘GetWSDebiteringsunderlagStatus.Debiteringsunderlag.Reference'”
Msg_Request.KallaID = Msg_Teledatabasen_XML.KallaID;How can I fix this problem. Please
-
June 30, 2008 at 8:12 AM #20025
It looks like you are trying to populate a distinguished field on the web service request message with data from a distinguished field on the inbound message. It seems the data types don’t match. What is the type of Msg_Request.DebiteringsunderlagsId? What is the type of Msg_Teledatabasen_XML.DebiteringsunderlagsId? Do you need an additional “.FieldName” on the end of Msg_Request.DebiteringsunderlagsId?
-
June 30, 2008 at 8:26 AM #20026
Russel, thanks for trying to help me, I appriciate it very much.
You are correct that the data type does not match.
Msg_Request.DebiteringsunderlagsId is int[]
Msg_Teledatabasen_XML.DebiteringsunderlagId is intHow can I make it match?
-
June 30, 2008 at 8:36 AM #20027
Ok, I added a .FieldName on the end of Msg_Teledatabasen_XML.DebiteringsunderlagsId so it became
Msg_Request.DebiteringsunderlagsId = Msg_Teledatabasen_XML.DebiteringsunderlagsId.int;
also tried with
Msg_Request.DebiteringsunderlagsId = Msg_Teledatabasen_XML.DebiteringsunderlagsId.int[];
-
June 30, 2008 at 8:47 AM #20028
It looks like you are using the SOAP adapter and have added a web reference to the web service? It also looks like the web reference generated a multipart message type to pass to the web service, and one of the parts is an int array? This is problematic in BizTalk because you can’t declare an array variable as far as I know. In my opinion, the best practice here would be to use the WCF adapter if you are on R2 or the WSE adapter if you are on R1. Both of these adapters will make your life easier than using the SOAP adapter, and the publishing wizards generate XML schemas, rather than multipart messages with array types. You might also want to check out this sample of cosuming web services with array parameters: http://www.biztalk247.com/v1/ContentTransformer.aspx?tag=89008B82-A30B-11DB-ABBB-5A8255D89593. I think it uses the SOAP adapter.
-
June 30, 2008 at 9:03 AM #20029
Here’s another idea: You could write a helper class that returns an int array, and just call it to initialize the array in your message. This might get around the inability to declare an array variable in BizTalk.
-
June 30, 2008 at 9:09 AM #20030
Correct, I am using the SOAP adapter.
The problem is that the web method takes int[], But I will never pass an array of int. I always will pass an int variable to web method.So it is not possible to pass int to int[]. I cannot convert it or something else?
-
June 30, 2008 at 9:15 AM #20031
I like your idea about write a helper class that returns an int array.
How can I do that And what is a Helper class?
You mean something like Msg_Request.DebiteringsunderlagsId = returnIntArray(Msg_Teledatabasen_XML.DebiteringsunderlagsId.int); and returnIntArray returns an array?
I appriciate that you having patience.-
June 30, 2008 at 10:29 AM #20033
You got it. You can just create a C# class library project and add a class to it. Define a method on the class that takes an int and returns an int array. Then, add a reference from the BizTalk project to the class library, and call the method in the orchestration to initialize the array: Example:
public static class IntHelper
{
public static int[] IntToIntArray(int number)
{
return new int[] { number };
}
}
Then call it from BizTalk like:
Msg_Request.DebiteringsunderlagsId = ItHelper.IntToIntArray(Msg_Teledatabasen_XML.DebiteringsunderlagsId.int);
-
July 1, 2008 at 5:30 AM #20043
Ok, I have created class library and paste your code so it looks lite this.
using System;
using System.Collections.Generic;
using System.Text;namespace Ncc.BizTalk.Core.WebService
{
[Serializable]
public static class Helper
{
public static int[] IntToIntArray(int number)
{
return new int[] { number };
}
}
}I am calling the helper class in the message assignment like this an it complains. This is how i look.

And this is my windows applicationcode

Russell, why does this not work?
Russell, I am very thankful for the help that you are helping me with -
July 1, 2008 at 5:32 AM #20044
What happen to the picture I dont know
This is the link to the first picture http://www40.brinkster.com/aspvbnerd/IntToArray.jpgAnd this is the second link
http://www40.brinkster.com/aspvbnerd/webservice.jpg -
July 1, 2008 at 6:57 AM #20045
What is the full error message in the expression editor? I can tell it’s a type mismatch, but the end of the message got cut off. We know the helper class returns an int array, so I suspect that “Msg_Request.DebiteringsunderlagsId” is not of type int[].
-
July 1, 2008 at 7:29 AM #20046
Here is a another picture of the error message http://www40.brinkster.com/aspvbnerd/IntToIntArray.jpg
Hope you can help me
-
July 1, 2008 at 7:44 AM #20047
I think you are assigning the int array from the helper class to the wrong thing. You really need to examine the structure of the web service request message and pay close attention to the field types. If you type a dot on the end of “Msg_Request.DebiteringsunderlagsId”, do you see any additional field names?
-
July 1, 2008 at 8:31 AM #20048
I didnt notice that your response was on the second page. [:)]
This a part of the wsdl file of HamtaStatus<wsdl:types>
<s:schema elementFormDefault=”qualified” targetNamespace=”http://debiteringsunderlag.se/“>
<s:element name=”hamtaStatus”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”DebiteringsunderlagsId” type=”tns:ArrayOfInt” />
<s:element minOccurs=”1″ maxOccurs=”1″ name=”KallaID” type=”s:int” />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name=”ArrayOfInt”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”unbounded” name=”int” type=”s:int” />
</s:sequence>
</s:complexType>
<s:element name=”hamtaStatusResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”hamtaStatusResult” type=”tns:Status” />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name=”Status”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”underlag” type=”tns:ArrayOfUnderlag” />
</s:sequence>
</s:complexType>
<s:complexType name=”ArrayOfUnderlag”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”unbounded” name=”underlag” nillable=”true” type=”tns:underlag” />
</s:sequence>
</s:complexType>
<s:complexType name=”underlag”>
<s:sequence>
<s:element minOccurs=”1″ maxOccurs=”1″ name=”DebiteringsunderlagsID” type=”s:int” />
<s:element minOccurs=”1″ maxOccurs=”1″ name=”StatusID” type=”s:int” />
<s:element minOccurs=”0″ maxOccurs=”1″ name=”Status” type=”s:string” />
<s:element minOccurs=”0″ maxOccurs=”1″ name=”Meddelande” type=”s:string” />
</s:sequence>
</s:complexType>This is what I can found on when surfing to web of HamtaStatus
POST /duws/du.asmx HTTP/1.1
Host: sesoaw252
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: “http://debiteringsunderlag.se/hamtaStatus“<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/“>
<soap:Body>
<hamtaStatus xmlns=”http://debiteringsunderlag.se/“>
<DebiteringsunderlagsId>
<int>int</int>
<int>int</int>
</DebiteringsunderlagsId>
<KallaID>int</KallaID>
</hamtaStatus>
</soap:Body>
</soap:Envelope> -
July 1, 2008 at 8:39 AM #20049
I didnt notice that your response was on the second page. [:)]
This a part of the wsdl file of HamtaStatus<wsdl:types>
<s:schema elementFormDefault=”qualified” targetNamespace=”http://debiteringsunderlag.se/“>
<s:element name=”hamtaStatus”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”DebiteringsunderlagsId” type=”tns:ArrayOfInt” />
<s:element minOccurs=”1″ maxOccurs=”1″ name=”KallaID” type=”s:int” />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name=”ArrayOfInt”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”unbounded” name=”int” type=”s:int” />
</s:sequence>
</s:complexType>
<s:element name=”hamtaStatusResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”hamtaStatusResult” type=”tns:Status” />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name=”Status”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”underlag” type=”tns:ArrayOfUnderlag” />
</s:sequence>
</s:complexType>
<s:complexType name=”ArrayOfUnderlag”>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”unbounded” name=”underlag” nillable=”true” type=”tns:underlag” />
</s:sequence>
</s:complexType>
<s:complexType name=”underlag”>
<s:sequence>
<s:element minOccurs=”1″ maxOccurs=”1″ name=”DebiteringsunderlagsID” type=”s:int” />
<s:element minOccurs=”1″ maxOccurs=”1″ name=”StatusID” type=”s:int” />
<s:element minOccurs=”0″ maxOccurs=”1″ name=”Status” type=”s:string” />
<s:element minOccurs=”0″ maxOccurs=”1″ name=”Meddelande” type=”s:string” />
</s:sequence>
</s:complexType> -
July 1, 2008 at 8:41 AM #20050
This is what I found on when surfing to web of HamtaStatus
POST /duws/du.asmx HTTP/1.1
Host: sesoaw252
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: “http://debiteringsunderlag.se/hamtaStatus“<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/“>
<soap:Body>
<hamtaStatus xmlns=”http://debiteringsunderlag.se/“>
<DebiteringsunderlagsId>
<int>int</int>
<int>int</int>
</DebiteringsunderlagsId>
<KallaID>int</KallaID>
</hamtaStatus>
</soap:Body>
</soap:Envelope> -
July 1, 2008 at 8:52 AM #20051
If I type a dot at the end of “Msg_Request.DebiteringsunderlagsId” I dont see any additional field names
-
July 1, 2008 at 9:14 AM #20052
Sorry about the double post
-
-
-
-
-
-
-
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.