none
Biztalk problem with schema elements which have hyphens

    Question

  • Hi!


    I have webservice that i need to call in Biztalk orchestration. Webservice offers to schemas.  The schemas have some problems in the elements because they contain hyphens.

    I can't also access the root element in the orchestration messageproperties. Element is called "Export-Request" but if I remove the hyphen it will show fine.

    I found this thread http://www.eggheadcafe.com/software/aspnet/30776220/xml-elements-with-hyphens.aspx
    but I don't think this helps much because I can't promote needed elements.

    Does someone know how to get past this annoying problem?

    thanks Raine

    • Edited by Raine2 Wednesday, June 17, 2009 12:08 PM corrections
    Wednesday, June 17, 2009 12:03 PM

Answers

  • You can use your original schema with some modification. The schema file is compiled into a C# class and all root nodes (children of <schema>) are given .NET type names that match their element name. This can be overridden. Select each root node, go to the properties tab and scroll to Rootnode Typename and remove the hyphen.

    The second issue is distinguished field and property promotion. You will be unable to use distinguished fields and will have to use promoted properties. This involves creating a property schema and  adding an element for each property you wish to promote (set the Property Schema Base for eacdh property to MessagePropertyContextBase). In the schema navigate to Promote->Show Properties-> Property Fields Tab, add you property schema and then assign the promoted properties.

    In your orchestration you will use:
    Message(YourNamespace.YourProperty) = value

    instead of:
    Message.Your-Property = value;

    • Marked as answer by Raine2 Thursday, June 18, 2009 9:32 AM
    Wednesday, June 17, 2009 7:32 PM
    Answerer

All replies

  • Hi Raine,

    1) Try accessing the web service created schema in the biztalk mapper and check if you can populate the elements there

    OR

    2)You can create a wrapper around this web service ( using C#) and then invoke the web service by calling the
    assembly or the wrapper web service.

    Regds,
    Ratnakar.
    Wednesday, June 17, 2009 12:12 PM
  • Hi Ratnakar.

    Thanks for your quick reply. Problem is that these schemas aren't generated by Biztalk. Biggest problem is that Schema validation fails so I can't use right elements even in the mapper. I can't even generate instance of these schemas. Build fails also because the validation fails. By the way response schema also contains hyphens.

    I think this is some kind of bug in Visual Studio. I think i had error that said something about using illegal characters..

    It all comes back to the (-) hyphens. I don't know how to create a wrapper?

    thanks Raine

    Wednesday, June 17, 2009 12:30 PM
  • Wht does this mean? "these schemas aren't generated by Biztalk". Are you saying that u added a web reference and the schema was not generated? Are you getting any compilation errors? Also, try generating the instance after setting the Validation flag to False in the schema property window.

    You can create a wrapper by developing a method in .Net (C#,VB.Net) and invoke the webservice from within the method.
    Wednesday, June 17, 2009 12:40 PM
  • I got these schemas from the webserviceprovider who provide the webservice. I need to send xml to webservice and get the answer xml. I tested add web reference but it doesn't work for me.. get multiple errors.

    I think this webservice which I'm calling is bit old fashioned. It doesn't use SOAP. The schemas which i'm struggling with were originally DTDs... So I converted them with Altova Xml Spy. The schemas pass fine Xml Spy validation.

    thanks Raine
    Wednesday, June 17, 2009 12:47 PM
  • Hi,

    You can try calling the web services without using web references, may be this will help in your scenario.

    http://abdulrafaysbiztalk.wordpress.com/2009/04/26/consuming-web-services-in-an-orchestration-using-dynamic-port-binding-and-without-web-reference/


    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Wednesday, June 17, 2009 1:18 PM
  • Thanks Abdul.

    But I think this is not the case. The webservice which i'm calling doesn't contain any wsdl files.. I think..
    Wednesday, June 17, 2009 1:32 PM
  • Ok lets see, copy and paste the URL of the web service which you used for adding the web reference and then append ?wsdl with the URL and I hope you can get the wsdl of your web service. Give it a try...


    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Wednesday, June 17, 2009 2:15 PM
  • Hi Abdul!

    I see your point. This webservice doesn't use wsdl/soap. I tried appending ?wsdl at the end of URL. I think only way to call this old webservice is to send xml file to it and wait for a answer.

    By the way I have a little java program as example which i got from the webserviceproviders. In this program they just send xml-file as a string to this webservice URL. The java program waits for the answer..

    Unfortunately the webserviceprovider dudes are on vacation right now so I can't get any help from them right now..

    thanks Raine.
    Wednesday, June 17, 2009 2:40 PM
  • I think you can invoke like this

    <System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/YourWebserviceName/YourWebserviceClass/YourWebserviceMethod", RequestNamespace:="http://tempuri.org/YourWebserviceName/YourWebserviceClass", ResponseNamespace:="http://tempuri.org/YourWebserviceName/YourWebserviceClass", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _
            Public Function YourWebservicFunction(Byval YourWebserviceParameter1, and so on) As String
                Dim results() As Object = Me.Invoke("YourWebserviceFunction", New Object() {YourWebserviceParameter1, and so on})
                Return CType(results(0),String)
            End Function
    KiranMP
    Wednesday, June 17, 2009 2:45 PM
  • Thanks for your suggestion.. KiranMP

    This webservice which i'm trying to call doesn't use http://tempuri.org as a namespace. I tried to set straight to URL your suggestions.

    "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

    I don't really know what namespace they are using because those DTD-files don't show namespaces..
    • Edited by Raine2 Wednesday, June 17, 2009 3:08 PM add
    Wednesday, June 17, 2009 3:07 PM
  • Hi,

    You have to use System.String as a request message type and assign the requst xml which they have given you to the string. Configure the port type and the message type as System.String. Also it will return a System.String so you have to make a Response Message of type System.String.
    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Wednesday, June 17, 2009 4:50 PM
  • Hi,

    This could work. Could you be more specific how to assign the xml to the string. I'm testing my orchestration with filedrop locations..

    Thanks Raine
    Wednesday, June 17, 2009 5:04 PM
  • First of all you have to see what your xml looks like. You can generate the schema of your xml if you have the sample xml. In your orchestration you will use this message for transformations or whatever you like. From your previous posts you have just mentioned that you want to call a web service and thats what all we know. Whenever yo are calling your web service you can use another Message of type System.String and this will be your request message. As an intermediate step convert your Message(of type generated from your sample XML) into a System.Xml.XMLDocument variable. You can just assign a message to a variable of this type.

    xDocVar = MessageOfSchemaTypeGeneratedFromSample;

    RequestMessageOfTypeString = xDocVar.OuterXml;

    Just make sure that whatever you get from xDocVar.OuterXml should exactly match your sample xml. You can print it in the event log by System.Diagnostics.EventLog.WriteEntry("PrimitiveTypeMessage", xDocVar.OuterXml);

    Make sure that the string is exact otherwise the webservice will not be able to parse your request.


    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this answer if it helps
    Wednesday, June 17, 2009 5:17 PM
  • Hi!

    Thanks Abdul. I will try your solution littlebit later. The problem with this solution might be that i can't use these xml-files dynamically like to do mappings and so on.

    Meanwhile I tried to convert my DTD:s to Schema again with Biztalk. I got the original message from schema validation:

    Invoking component...
    C:\XSD-path\  error BEC2012: Node "export-request" - Specify a valid .NET type name for this root node. The current .NET type name of this root node is invalid (it is a reserved BizTalk Keyword or is an invalid C# identifier).

    So this is the original error and problem. I think it would be so easy just send the xml to webservice trough physical port. Somebody must have problems with "Hyphens" :)


    Wednesday, June 17, 2009 5:46 PM
  • You can use your original schema with some modification. The schema file is compiled into a C# class and all root nodes (children of <schema>) are given .NET type names that match their element name. This can be overridden. Select each root node, go to the properties tab and scroll to Rootnode Typename and remove the hyphen.

    The second issue is distinguished field and property promotion. You will be unable to use distinguished fields and will have to use promoted properties. This involves creating a property schema and  adding an element for each property you wish to promote (set the Property Schema Base for eacdh property to MessagePropertyContextBase). In the schema navigate to Promote->Show Properties-> Property Fields Tab, add you property schema and then assign the promoted properties.

    In your orchestration you will use:
    Message(YourNamespace.YourProperty) = value

    instead of:
    Message.Your-Property = value;

    • Marked as answer by Raine2 Thursday, June 18, 2009 9:32 AM
    Wednesday, June 17, 2009 7:32 PM
    Answerer
  • Hi Greg!

    This sounds very good. I'll try this tomorrow and report how it goes.

    Thanks Raine
    Wednesday, June 17, 2009 7:42 PM
  • Hi to you all!

    This Gregs answer worked! Now i'm just hoping that rest of this application will work! :)

    Thank you all for your quick responses... I see this forum is a great place to find true professionals :)

    Raine
    Thursday, June 18, 2009 9:32 AM
  • Hi Greg.  I understand the part about the compiler using the node names in the compiled class, but don't get what you mean by "all root nodes are given .NET type names".

    The xml my customer is sending has hyphens in almost every xml element and attribute name.  VS only permits me to modify the Rootnode Typename property for the root node and their structure has only one root node.

    What am i missing?


    Doug Griffin

    Thursday, September 26, 2013 4:21 PM