Mombu the Programming Forum

Go Back   Mombu the Programming Forum > Programming > Complex soap messages with structures
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 31st March 05:49
yhhuang
External User
 
Posts: 1
Default Complex soap messages with structures



Hi Daniel,

I tested my client in VS.NET and it works fine.

Here is the soap request that I got from trace tool:

<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <standard xmlns="urn:VerifyStatus">
- <key>
<partnerKey>testPartner</partnerKey>
<companyKey>testCompany</companyKey>
</key>
</standard>
</soap:Body>
</soap:Envelope>

SOAP response:

<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <standardResponse xmlns="standard">
- <return>
<partnerKey>testPartner</partnerKey>
<companyKey>testCompany</companyKey>
<dt>2003-09-05T17:57:15.5403220+08:00</dt>
</return>
</standardResponse>
</soap:Body>
</soap:Envelope>

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!Content-Class: urn:content-classes:message
!From: "Dan" <daniel_meland@msn.com>
!Sender: "Dan" <daniel_meland@msn.com>
!References: <0e2d01c36d84$51e9e6e0$a601280a@phx.gbl>
<oy#dkWgbDHA.1628@cpmsftngxa06.phx.gbl>
<070b01c36fc2$d981d910$a101280a@phx.gbl>
<4#fwUAgcDHA.1932@cpmsftngxa06.phx.gbl>
!Subject: RE: Complex soap messages with structures
!Date: Thu, 4 Sep 2003 09:41:53 -0700
!Lines: 499
!Message-ID: <1f4101c37303$727f0910$a401280a@phx.gbl>
!MIME-Version: 1.0
!Content-Type: text/plain;
! charset="iso-8859-1"
!Content-Transfer-Encoding: 7bit
!X-Newsreader: Microsoft CDO for Windows 2000
!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!Thread-Index: AcNzA3J86GK2LqxES5OqaSQaTLWCbg==
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
!Path: cpmsftngxa06.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservic es:19188
!NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
!
!Yes that is correct.
!In HTTP the objet gets there however using the soapscope
!and sending the raw SOAP message it does not work and is
!null.
!
!Here is the code:
!
!?
!################################################# ##########
!####?
!
!SERVICE PART
!
!?
!################################################# ##########
!####?
!
!
!using System;
!using System.Collections;
!using System.ComponentModel;
!using System.Data;
!using System.Diagnostics;
!using System.Web;
!using System.Web.Services;
!using System.Web.Services.Protocols;
!using System.Web.Services.Description;
!using System.Xml;
!using System.Xml.Serialization;
!
!namespace test
!{
!
! /// <summary>
! /// Summary description for Service1.
! /// </summary>
! [WebServiceAttribute(Name="embrasure",
!Namespace="urn:embrasure")]
!/* [SoapRpcService(
!RoutingStyle=SoapServiceRoutingStyle.SoapAction)]*/
! public class Service1 :
!System.Web.Services.WebService
! {
! public Service1()
! {
! //CODEGEN: This call is required
!by the ASP.NET Web Services Designer
! InitializeComponent();
! }
!
! #region Component Designer generated code
!
! //Required by the Web Services Designer
! private IContainer components = null;
!
! /// <summary>
! /// Required method for Designer support -
!do not modify
! /// the contents of this method with the
!code editor.
! /// </summary>
! private void InitializeComponent()
! {
! }
!
! /// <summary>
! /// Clean up any resources being used.
! /// </summary>
! protected override void Dispose( bool
!disposing )
! {
! if(disposing && components != null)
! {
! components.Dispose();
! }
! base.Dispose(disposing);
!
! }
!
! #endregion
!
! // WEB SERVICE EXAMPLE
! // The HelloWorld() example service
!returns the string Hello World
! // To build, uncomment the following lines
!then save and build the project
! // To test this web service, press F5
!
! [WebMethod]
! [SoapDocumentMethod("standard",
!
!RequestNamespace="urn:VerifyStatus",
! RequestElementName="standard",
! ResponseNamespace="standard",
!
!ResponseElementName="standardResponse",
! Use=SoapBindingUse.Literal)]
! [return: XmlElement("return")]
! public mykey2 standard([XmlElement
!(Type=typeof(messagekey), Namespace="urn:VerifyStatus")]
! messagekey key)
! {
! mykey2 ky = new mykey2();
! ky.partnerKey=key.partnerKey;
! ky.companyKey=key.companyKey;
! ky.dt= DateTime.Now;
! return ky;
! }
! }
!
!
! public class messagekey
! {
! public string partnerKey;
! public string companyKey;
! }
!
! [XmlRoot("return")]
! public class mykey2
! {
! public string partnerKey;
! public string companyKey;
!
! public DateTime dt=DateTime.Now;
! }
!}
!
!
!Calls are made as raw SOAP messages.
!Here is the incoming soap call:
!
!<SOAP-ENV:Envelope
! xmlns:SOAP-
!ENV="http://schemas.xmlsoap.org/soap/envelope/"
! xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
! xmlns:xsd="http://www.w3.org/1999/XMLSchema"
! xmlns:xe="urn:embrasure"
! xmlns:xe1="urn:VerifyStatus"
! xmlns:xe2="http://schemas.xmlsoap.org/soap/encoding/"
! >
! <SOAP-ENV:Body>
! <xe1:standard SOAP-
!ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding
!/" >
! <xe1:key xsi:type="xe:messagekey">
! <partnerkey
!xsi:type="xsd:string">Embasure</partnerkey>
! <companykey
!xsi:type="xsd:string">PHTRopphile,disney</companykey>
! </xe1:key>
! </xe1:standard>
! </SOAP-ENV:Body>
!</SOAP-ENV:Envelope>
!
!
!I am using SoapScope as a client to the service
!
!THanks for the help
!Dan
!
!
!>-----Original Message-----
!>Hello Daniel,
!>
!>Thanks for posting in the group.
!>
!>After reviewing all all the thread, I summary the
!question as the following:
!>You use SOAP to call a web method in a web service, the
!input parameter
!>messagekey becomes null when transferred into web
!service. However, if in
!>HTTP call, the parameter could be got successfully in web
!method. Please
!>post here if I have misunderstood anything.
!>
!>Could you please send me a small repro sample include web
!service, SOAP
!>client and HTTP client? I will test it on my side to
!reproduce the problem.
!>When debugging, we could use SOAP trace tool to check
!input and output on
!>web service side to see where the error happens. You
!could also use SOAP
!>trace tool at
!>http://msdn.microsoft.com/library/default.asp?
!url=/library/en-us/soap/htm/so
!>ap_overview_5y49.asp.
!>
!>
!>Best regards,
!>Yanhong Huang
!>Microsoft Online Partner Support
!>
!>Get Secure! - www.microsoft.com/security
!>This posting is provided "AS IS" with no warranties, and
!confers no rights.
!>
!>--------------------
!>!Content-Class: urn:content-classes:message
!>!From: "Dan" <daniel_meland@msn.com>
!>!Sender: "Dan" <daniel_meland@msn.com>
!>!References: <0e2d01c36d84$51e9e6e0$a601280a@phx.gbl>
!><oy#dkWgbDHA.1628@cpmsftngxa06.phx.gbl>
!>!Subject: RE: Complex soap messages with structures
!>!Date: Sun, 31 Aug 2003 06:21:56 -0700
!>!Lines: 252
!>!Message-ID: <070b01c36fc2$d981d910$a101280a@phx.gbl>
!>!MIME-Version: 1.0
!>!Content-Type: text/plain;
!>! charset="iso-8859-1"
!>!Content-Transfer-Encoding: 7bit
!>!X-Newsreader: Microsoft CDO for Windows 2000
!>!X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
!>!Thread-Index: AcNvwtl/e/n6IATETsKcVR5lW4ZWSg==
!>!Newsgroups:
!microsoft.public.dotnet.framework.aspnet.webservi ces
!>!Path: cpmsftngxa06.phx.gbl
!>!Xref: cpmsftngxa06.phx.gbl
!>microsoft.public.dotnet.framework.aspnet.webserv ices:19121
!>!NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
!>!X-Tomcat-NG:
!microsoft.public.dotnet.framework.aspnet.webservi ces
!>!
!>!
!>!You are correct. but I cant expose the timestamp field.
!>!
!>!The messages work correct if they are sent via http.
!The
!>!problem comes in the SoapRPC message over the wire.
!>!
!>!I used SoapScope to send the raw message and that is
!when
!>!the problem occurs.
!>!
!>!Seems that the messagekeys passed in is always null.
!>!
!>!My system is a win200 with VS.Net 2003.
!>!
!>!I believe the problem is in the formatting.
!>!
!>!Thanks Lewis
!>!
!>!>-----Original Message-----
!>!>Hi Dan,
!>!>
!>!>I created a webservice and used the code you provided.
!>!Everything appears
!>!>to be okay on my machine. My OS is win2000 server and
!is
!>!running VS.NET
!>!>2003.
!>!>
!>!>In the last code snippet of the soap massage, I found
!>!that it should be a
!>!>description of the class keys not the class messagekey.
!>!There are only 2
!>!>public fields for the class messagekey, but the
!following
!>!has 3 public
!>!>fields.
!>!>
!>!><SOAP-ENV:Envelope
!>!>xmlns:SOAP-
!>!ENV="http://schemas.xmlsoap.org/soap/envelope/"
!>!>xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
!>!>xmlns:xsd="http://www.w3.org/1999/XMLSchema" >
!>!><SOAP-ENV:Body>
!>!><ns1:standardResponse xmlns:ns1="urn:VerifyStatus"
!>!>SOAP-
!>!
!NV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/
!>!">
!>!>
!>!> <return xmlns:ns2="urn:mine"
!>!xsi:type="ns2:messagekey"> (It should
!>!>be "keys" not "messagekey".)
!>!>
!>!> <partnerkey xsi:type="xsd:string">PARTNER
!>!KEY</partnerkey>
!>!> <companykey xsi:type="xsd:string">COMPANY
!>!KEY</companykey>
!>!> <timestamp xsi:type="xsd:date">YYYY-MM-DD
!>!HH24:MI:SS </timestamp>
!>!> </return>
!>!> </ns1:standardResponse>
!>!> </SOAP-ENV:Body>
!>!></SOAP-ENV:Envelope>
!>!>
!>!>Based on the current problem description I am still a
!bit
!>!unclear about
!>!>several points. Which version of VS.NET are you using
!to
!>!develop the web
!>!>service? Also, could you please provide me with more
!>!information about what
!>!>it is exactly that you would like to achieve. I am
!>!looking forward to your
!>!>reply.
!>!>
!>!>Best regards,
!>!>Lewis
!>!>
!>!>This posting is provided "AS IS" with no warranties,
!and
!>!confers no rights.
!>!>
!>!>--------------------
!>!>| Content-Class: urn:content-classes:message
!>!>| From: "Dan" <daniel_meland@msn.com>
!>!>| Sender: "Dan" <daniel_meland@msn.com>
!>!>| Subject: Complex soap messages with structures
!>!>| Date: Thu, 28 Aug 2003 09:49:17 -0700
!>!>| Lines: 141
!>!>| Message-ID: <0e2d01c36d84$51e9e6e0$a601280a@phx.gbl>
!>!>| MIME-Version: 1.0
!>!>| Content-Type: text/plain;
!>!>| charset="iso-8859-1"
!>!>| Content-Transfer-Encoding: 7bit
!>!>| X-Newsreader: Microsoft CDO for Windows 2000
!>!>| Thread-Index: AcNthFHpDxuuN49YRC2pLv5pbuXFRg==
!>!>| X-MimeOLE: Produced By Microsoft MimeOLE
!V5.50.4910.0300
!>!>| Newsgroups:
!>!microsoft.public.dotnet.framework.aspnet.webser vices
!>!>| Path: cpmsftngxa06.phx.gbl
!>!>| Xref: cpmsftngxa06.phx.gbl
!>!
!>microsoft.public.dotnet.framework.aspnet.webserv ices:19072
!>!>| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
!>!>| X-Tomcat-NG:
!>!microsoft.public.dotnet.framework.aspnet.webser vices
!>!>|
!>!>| OK, I am having a problem getting the xml to format
!>!for
!>!>| this soap message.
!>!>|
!>!>| <SOAP-ENV:Envelope xmlns:SOAP-
!>!>| ENV="http://schemas.xmlsoap.org/soap/envelope/"
!>!>| xmlns:xsi="http://www.w3.org/1999/XMLSchema-
!instance"
!>!>| xmlns:xsd="http://www.w3.org/1999/XMLSchema"
!>!>| xmlns:xe="urn:mine"
!>!>| xmlns:xe1=" urn:VerifyStatus"
!>!>|
!xmlns:xe2="http://schemas.xmlsoap.org/soap/encoding/"
!>!>| >
!>!>| <SOAP-ENV:Body>
!>!>| <xe1:standard SOAP-
!>!>|
!>!
!ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding
!>!>| /" >
!>!>| <xe1:key xsi:type="xe:messagekey">
!>!>| <partnerkey
!>!>| xsi:type="xsd:string">someguy</partnerkey>
!>!>| <companykey
!>!>| xsi:type="xsd:string">blah,blah</companykey>
!>!>| </xe1:key>
!>!>| </xe1:standard>
!>!>| </SOAP-ENV:Body>
!>!>| </SOAP-ENV:Envelope>
!>!>|
!>!>| Can anyone help.
!>!>|
!>!>| here is the webmethod:
!>!>|
!>!>| [WebMethod (Description="Validate SOAP
!>!>| server availability and Message Key integrity")]
!>!>| [TraceExtension()]
!>!>| [SoapDocumentMethod
!>!>| ("http://172.17.89.26/standard",
!>!>|
!>!>| RequestNamespace="http://172.17.89.26/standard",
!>!>|
!>!>|
!>!ResponseNamespace="http://172.17.89.26/standardResponse",
!>!>| Use=SoapBindingUse.Encoded)
!>!>| ]
!>!>| public keys standard([XmlElement("key")] messagekey
!key)
!>!>| {
!>!>| keys kys = new keys();
!>!>| //Make sure Embrasure is who is calling us
!>!>| if(key.partnerKey.CompareTo("Embrasure") == 0)
!>!>| {
!>!>| // Validate the login and Embrasure
!>!>| string[] ks = getkey(key.partnerKey,
!>!key.companyKey);
!>!>|
!>!>| kys.partnerKey = ks[0];
!>!>| kys.companyKey = ks[1];
!>!>|
!>!>| }
!>!>| return kys;
!>!>|
!>!>| }
!>!>|
!>!>| here is the messagekey class:
!>!>| [XmlRoot("key")]
!>!>| public class messagekey
!>!>| {
!>!>| public string partnerKey="";
!>!>| public string companyKey = "";
!>!>| public messagekey()
!>!>| {
!>!>| }
!>!>| }
!>!>|
!>!>| and the responding keys class
!>!>| [XmlRoot("return")]
!>!>| public class keys
!>!>| {
!>!>| public string partnerKey="";
!>!>| public string companyKey = "";
!>!>| [XmlElement("timestamp")]
!>!>| public DateTime timestamp;
!>!>| public keys()
!>!>| {
!>!>| timestamp=DateTime.Now;
!>!>| }
!>!>|
!>!>| }
!>!>|
!>!>|
!>!>| <SOAP-ENV:Envelope xmlns:SOAP-
!>!>| ENV="http://schemas.xmlsoap.org/soap/envelope/"
!>!>| xmlns:xsi="http://www.w3.org/1999/XMLSchema-
!instance"
!>!>| xmlns:xsd="http://www.w3.org/1999/XMLSchema"
!>!>| xmlns:xe="urn:mine"
!>!>| xmlns:xe1=" urn:VerifyStatus"
!>!>|
!xmlns:xe2="http://schemas.xmlsoap.org/soap/encoding/"
!>!>| >
!>!>| <SOAP-ENV:Body>
!>!>| <xe1:standard SOAP-
!>!>|
!>!
!ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding
!>!>| /" >
!>!>| <xe1:key xsi:type="xe:messagekey">
!>!>| <partnerkey
!>!>| xsi:type="xsd:string">someguy</partnerkey>
!>!>| <companykey
!>!>| xsi:type="xsd:string">blah,blah</companykey>
!>!>| </xe1:key>
!>!>| </xe1:standard>
!>!>| </SOAP-ENV:Body>
!>!>| </SOAP-ENV:Envelope>
!>!>|
!>!>| the response should look like this.
!>!>| <SOAP-ENV:Envelope
!>!>| xmlns:SOAP-
!>!>| ENV="http://schemas.xmlsoap.org/soap/envelope/"
!>!>| xmlns:xsi="http://www.w3.org/1999/XMLSchema-
!instance"
!>!>| xmlns:xsd="http://www.w3.org/1999/XMLSchema"
!>!>| >
!>!>| <SOAP-ENV:Body>
!>!>| <ns1:standardResponse xmlns:ns1="urn:VerifyStatus"
!>!>| SOAP-
!>!>|
!>!
!ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding
!>!>| /">
!>!>| <return xmlns:ns2="urn:mine"
!>!>| xsi:type="ns2:messagekey">
!>!>| <partnerkey xsi:type="xsd:string">PARTNER
!>!>| KEY</partnerkey>
!>!>| <companykey xsi:type="xsd:string">COMPANY
!>!>| KEY</companykey>
!>!>| <timestamp xsi:type="xsd:date">YYYY-MM-DD
!>!>| HH24:MI:SS </timestamp>
!>!>| </return>
!>!>| </ns1:standardResponse>
!>!>| </SOAP-ENV:Body>
!>!>| </SOAP-ENV:Envelope>
!>!>|
!>!>|
!>!>| I cant get the response nor does the method see the
!>!>| message object being passed in.
!>!>|
!>!>| Does any one have any ideas. I dont want to hack teh
!>!XML
!>!>| stream going out.
!>!>|
!>!>| Thanks
!>!>| Dan
!>!>|
!>!>|
!>!>
!>!>.
!>!>
!>!
!>
!>.
!>
!
  Reply With Quote


 


Reply


Thread Tools
Display Modes




666