By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,208 Members | 1,592 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,208 IT Pros & Developers. It's quick & easy.

badly formed XML when calling a web service

P: n/a
AI am trying to call a third-party web service. this service expects an XML
fragment that contains the request plus other parameter. adding the web
reference created the syntax below(reference.vb).

I changed the data type for the structure that contains the XML data from
the default "String" to "xml.xmldocument" to enable easy filling of the
data.

my client code creates an XML document class, fills the data using standard
xml dom calls, and then invokes the web service.

the server refuses my call because the XML element below the root element
(customerGeneralInquiryRequests ) contains an empty "xmlns" attribute. How
do I get rid of it? I tried to define PDataXML as a node, explicitly declare
the namespace as "nothing" when calling "CreateElement", nothing helps!

attached: samples from the reference file, my code that fills the XML
framgment, the WSDL retrieved from the web serrver, and from the output
trace.

any help will be appreciated!
note: a second question. the process by which the "p0" and "PDataXML"
elements are created in the request body are unclear to me. can anyone
explain or refer to good explanations? thanks!
---- FROM the client code --------------------------
Dim svc As New ServiceRootSoap

<SNIPPED CODE>

Dim aResult As CallServiceResponse

Dim aRequest As New CallService

Dim aRootNode, aDataNode As XmlNode

Dim aXMLDoc As New XmlDocument

aRootNode = aXMLDoc.CreateElement(Nothing, "customerGeneralInquiryRequests",
Nothing)

aXMLDoc.AppendChild(aRootNode)

<SNIPPED CODE>
aRequest.PDataXML = aXMLDoc

Try

aResult = svc.CallService(aRequest)

---- END OF from client code ----------------------

---- FROM reference.vb -------------------------------
<System.Web.Services.Protocols.SoapHeaderAttribute ("scsServiceHeader"), _
System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://webservice
s.hedberg.comServiceRootSoap#CallService?KExzdGVlb GNhc2Uvc2VydmV"& _
"yL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2U7KUxzdGVlbGNh c2Uvc2VydmVyL2lmYWNlcy9zdH
J1Y3Q"& _

"vQ2FsbFNlcnZpY2VSZXNwb25zZTs=",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Bare)>
_Public Function
CallService(<System.Xml.Serialization.XmlElementAt tribute([Namespace]:="http
://systinet.com/xsd/SchemaTypes/", IsNullable:=true)> ByVal p0 As
CallService) As
<System.Xml.Serialization.XmlElementAttribute("Cal lServiceResponse_Response"
, [Namespace]:="http://systinet.com/xsd/SchemaTypes/", IsNullable:=true)>
CallServiceResponse

Dim results() As Object = Me.Invoke("CallService", New Object() {p0})

Return CType(results(0),CallServiceResponse)

End Function

...........

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://systinet.com
/wsdl/steelcase/server/ifaces/struct/")> _

Public Class CallService
'<remarks/>

<System.Xml.Serialization.XmlElementAttribute(IsNu llable:=True)> _

Public PDataXML As Xml.XmlDocument 'string

.......

---- END OF from reference.vb ----------------------------------

---- FROM the output trace ---------------------------------------
<soap:Body wsu:Id="Id-61872b1c-682f-49eb-9c07-bd40aa4b42b1">
<p0 xmlns="http://systinet.com/xsd/SchemaTypes/">
<PDataXML
xmlns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">
<customerGeneralInquiryRequests xmlns="">
<customerGeneralInquiryRequest>
.........
---- END OF from the output trace ---------------------------------------


---- FROM the WSDL----------------------------------------------
.............
<xsd:complexType name="CallService">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallService" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="PDataXML" nillable="true" type="xsd:string" />

<xsd:element name="PInstructionsXML" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="CallServiceResponse">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallServiceRe sponse" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="callServiceResult" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

</s:schema>

<s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://systinet.com/xsd/SchemaTypes/"
xmlns:xns4="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
elementFormDefault="qualified"
targetNamespace="http://systinet.com/xsd/SchemaTypes/">

<xsd:import
namespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/" />

<xsd:element name="p0" nillable="true" type="xns4:CallService" />

<xsd:element name="CallServiceResponse_Response" nillable="true"
type="xns4:CallServiceResponse" />

</s:schema>

</wsdl:types>

<wsdl:message name="ServiceRootSoap_CallService_Response_Soap">

<wsdl:part name="response" element="s3:CallServiceResponse_Response" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_CallService__Request_Soap">

<wsdl:part name="p0" element="s3:p0" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_header_Soap">

<wsdl:part name="header_0" element="s2:scsServiceHeader" />

</wsdl:message>

<wsdl:message name="runtimeHeaders_0">

<wsdl:part name="header_0" element="s1:instance" />

<wsdl:part name="header_1" element="s0:TxId" />

</wsdl:message>

<wsdl:portType name="ServiceRootSoap">

<wsdl:operation name="CallService" parameterOrder="p0">

<wsdl:input message="tns:ServiceRootSoap_CallService__Request_ Soap" />

<wsdl:output message="tns:ServiceRootSoap_CallService_Response_ Soap" />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="ServiceRootSoap" type="tns:ServiceRootSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />

<wsdl:operation name="CallService">

<map:java-operation name="CallService"
signature="KExzdGVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ 1Y3QvQ2FsbFNlcnZpY2U7KUxzd
GVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZ pY2VSZXNwb25zZTs="
xmlns:map="http://systinet.com/mapping/" />

<soap:operation
soapAction="http://webservices.hedberg.comServiceRootSoap#CallService ?KExzdG
VlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZp Y2U7KUxzdGVlbGNhc2Uvc2Vydm
VyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2VSZXNwb25zZTs= " style="document" />

<wsdl:input>

<soap:body use="literal" parts="p0" />

<soap:header message="tns:ServiceRootSoap_header_Soap" part="header_0"
use="literal" />

</wsdl:input>

<wsdl:output>

<soap:body use="literal" parts="response" />

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="ServiceRootSoap">

<wsdl:port name="ServiceRootSoap" binding="tns:ServiceRootSoap">

<soap:address location="http://<deleted>/ServiceRoot" />

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

---------- END OF from the WSDL -----------------------------------------
Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Jerome,

There isn't enough of the WSDL Types section in your post to determine what
the right value for the namespace should be. If the WSDL is correctly
formed, add-web-reference should do the job. You shouldn't have to be
sending XML fragments - you can work with well formed classes (if you
prefer). If you are creating the XML nodes by hand, you should use
CreateNode instead of CreateElement so you can pass in the right namespace
value. The targetNamespace from the schema in the WSDL types section
should be the value you pass.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
From: "Jerome Cohen" <yo**********@structuredweb.com>
Subject: badly formed XML when calling a web service
Date: Tue, 14 Dec 2004 21:44:16 -0500
Lines: 273
Organization: SW
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <Op**************@TK2MSFTNGP14.phx.gbl>
Newsgroups:
microsoft.public.dotnet.framework.webservices,micr osoft.public.dotnet.framew
ork.webservices.enhancements,microsoft.public.webs ervices
NNTP-Posting-Host: 66.45.236.227
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices.enha ncements:5156
microsoft.public.webservices:2599
microsoft.public.dotnet.framework.webservices:8101
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

AI am trying to call a third-party web service. this service expects an XML
fragment that contains the request plus other parameter. adding the web
reference created the syntax below(reference.vb).

I changed the data type for the structure that contains the XML data from
the default "String" to "xml.xmldocument" to enable easy filling of the
data.

my client code creates an XML document class, fills the data using standard
xml dom calls, and then invokes the web service.

the server refuses my call because the XML element below the root element
(customerGeneralInquiryRequests ) contains an empty "xmlns" attribute. How
do I get rid of it? I tried to define PDataXML as a node, explicitly declare
the namespace as "nothing" when calling "CreateElement", nothing helps!

attached: samples from the reference file, my code that fills the XML
framgment, the WSDL retrieved from the web serrver, and from the output
trace.

any help will be appreciated!
note: a second question. the process by which the "p0" and "PDataXML"
elements are created in the request body are unclear to me. can anyone
explain or refer to good explanations? thanks!
---- FROM the client code --------------------------
Dim svc As New ServiceRootSoap

<SNIPPED CODE>

Dim aResult As CallServiceResponse

Dim aRequest As New CallService

Dim aRootNode, aDataNode As XmlNode

Dim aXMLDoc As New XmlDocument

aRootNode = aXMLDoc.CreateElement(Nothing, "customerGeneralInquiryRequests",
Nothing)

aXMLDoc.AppendChild(aRootNode)

<SNIPPED CODE>
aRequest.PDataXML = aXMLDoc

Try

aResult = svc.CallService(aRequest)

---- END OF from client code ----------------------

---- FROM reference.vb -------------------------------
<System.Web.Services.Protocols.SoapHeaderAttribute ("scsServiceHeader"), _
System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://webservice
s.hedberg.comServiceRootSoap#CallService?KExzdGVlb GNhc2Uvc2VydmV"& _
"yL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2U7KUxzdGVlbGNh c2Uvc2VydmVyL2lmYWNlcy9zdH
J1Y3Q"& _

"vQ2FsbFNlcnZpY2VSZXNwb25zZTs=",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Bare)>
_Public Function
CallService(<System.Xml.Serialization.XmlElementAt tribute([Namespace]:="http
://systinet.com/xsd/SchemaTypes/", IsNullable:=true)> ByVal p0 As
CallService) As
<System.Xml.Serialization.XmlElementAttribute("Cal lServiceResponse_Response"
, [Namespace]:="http://systinet.com/xsd/SchemaTypes/", IsNullable:=true)>
CallServiceResponse

Dim results() As Object = Me.Invoke("CallService", New Object() {p0})

Return CType(results(0),CallServiceResponse)

End Function

..........

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://systinet.com
/wsdl/steelcase/server/ifaces/struct/")> _

Public Class CallService
'<remarks/>

<System.Xml.Serialization.XmlElementAttribute(IsNu llable:=True)> _

Public PDataXML As Xml.XmlDocument 'string

......

---- END OF from reference.vb ----------------------------------

---- FROM the output trace ---------------------------------------
<soap:Body wsu:Id="Id-61872b1c-682f-49eb-9c07-bd40aa4b42b1">
<p0 xmlns="http://systinet.com/xsd/SchemaTypes/">
<PDataXML
xmlns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">
<customerGeneralInquiryRequests xmlns="">
<customerGeneralInquiryRequest>
........
---- END OF from the output trace ---------------------------------------


---- FROM the WSDL----------------------------------------------
............
<xsd:complexType name="CallService">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallService" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="PDataXML" nillable="true" type="xsd:string" />

<xsd:element name="PInstructionsXML" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="CallServiceResponse">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallServiceRe sponse" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="callServiceResult" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

</s:schema>

<s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://systinet.com/xsd/SchemaTypes/"
xmlns:xns4="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
elementFormDefault="qualified"
targetNamespace="http://systinet.com/xsd/SchemaTypes/">

<xsd:import
namespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/" />

<xsd:element name="p0" nillable="true" type="xns4:CallService" />

<xsd:element name="CallServiceResponse_Response" nillable="true"
type="xns4:CallServiceResponse" />

</s:schema>

</wsdl:types>

<wsdl:message name="ServiceRootSoap_CallService_Response_Soap">

<wsdl:part name="response" element="s3:CallServiceResponse_Response" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_CallService__Request_Soap">

<wsdl:part name="p0" element="s3:p0" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_header_Soap">

<wsdl:part name="header_0" element="s2:scsServiceHeader" />

</wsdl:message>

<wsdl:message name="runtimeHeaders_0">

<wsdl:part name="header_0" element="s1:instance" />

<wsdl:part name="header_1" element="s0:TxId" />

</wsdl:message>

<wsdl:portType name="ServiceRootSoap">

<wsdl:operation name="CallService" parameterOrder="p0">

<wsdl:input message="tns:ServiceRootSoap_CallService__Request_ Soap" />

<wsdl:output message="tns:ServiceRootSoap_CallService_Response_ Soap" />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="ServiceRootSoap" type="tns:ServiceRootSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />

<wsdl:operation name="CallService">

<map:java-operation name="CallService"
signature="KExzdGVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ 1Y3QvQ2FsbFNlcnZpY2U7KUxzd
GVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZ pY2VSZXNwb25zZTs="
xmlns:map="http://systinet.com/mapping/" />

<soap:operation
soapAction="http://webservices.hedberg.comServiceRootSoap#CallService ?KExzdG
VlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZp Y2U7KUxzdGVlbGNhc2Uvc2Vydm
VyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2VSZXNwb25zZTs= " style="document" />

<wsdl:input>

<soap:body use="literal" parts="p0" />

<soap:header message="tns:ServiceRootSoap_header_Soap" part="header_0"
use="literal" />

</wsdl:input>

<wsdl:output>

<soap:body use="literal" parts="response" />

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="ServiceRootSoap">

<wsdl:port name="ServiceRootSoap" binding="tns:ServiceRootSoap">

<soap:address location="http://<deleted>/ServiceRoot" />

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

---------- END OF from the WSDL -----------------------------------------

Nov 23 '05 #2

P: n/a
Dan,

thanks for the answer.

I think the problem is that the people who developed the web service treat
the "PDataXML" as a string. since when creating the XML doc the empty xmlns
was added to the root element, their server rejects the call. the error I am
getting from them is "Bad message : expected text, got start of element
{}customerGeneralInquiryRequests "
they claim the specific problem is that empty xmlns I get on the element
"customerGeneralInquiryRequests ". who is creating this? even when I changed
the code so it creates the whole xml document in one LoadXML call, I still
get this empty xmlns.

<PDataXML xmlns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">
<customerGeneralInquiryRequests xmlns="">
I am attaching the entire WSDL file

thanks, Jerome
------------------------------- WSDL
file ---------------------------------------------
<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions xmlns:s1="http://idoox.com/interface"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://systinet.com/soap-jta/"
xmlns:s3="http://systinet.com/xsd/SchemaTypes/"
xmlns:s2="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://webservices.hedberg.com"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://webservices.hedberg.com"
name="steelcase.server.ifaces.ServiceRootSoap"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<wsdl:types>

<s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://systinet.com/soap-jta/" elementFormDefault="qualified"
targetNamespace="http://systinet.com/soap-jta/">

<xsd:element name="TxId">

<xsd:complexType>

<xsd:sequence>

<xsd:element name="id" nillable="true" type="xsd:string" />

<xsd:element name="NoTxResume" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

</xsd:element>

</s:schema>

<s:schema xmlns:tns="http://idoox.com/interface"
xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://idoox.com/interface">

<s:complexType name="serviceReference">

<s:sequence>

<s:element name="service" type="s:QName" />

<s:element name="wsdl" type="s:anyURI" />

<s:element minOccurs="0" name="instanceID" type="s:string" />

<s:element minOccurs="0" name="portTypeMappings"
type="tns:ArrayOfInterfaceMapping" />

</s:sequence>

</s:complexType>

<s:complexType name="ArrayOfInterfaceMapping">

<s:sequence>

<s:element minOccurs="0" maxOccurs="unbounded" name="item"
type="tns:interfaceMapping" />

</s:sequence>

</s:complexType>

<s:complexType name="interfaceMapping">

<s:sequence>

<s:element name="portType" type="s:QName" />

<s:element name="className" type="s:string" />

</s:sequence>

</s:complexType>

<s:element name="instance">

<s:annotation>

<s:documentation>

this is the SOAP header schema

this SOAP header SHOULD have soap-env:mustUnderstand set to "1"

this header MUST be present at most once in any message

</s:documentation>

</s:annotation>

<s:complexType>

<s:choice>

<s:element name="id" type="s:string" />

<s:element name="setId" type="s:string" />

<s:element name="notFound" type="s:string" />

</s:choice>

</s:complexType>

</s:element>

</s:schema>

<s:schema
xmlns:tns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
xmlns:map="http://systinet.com/mapping/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">

<xsd:complexType name="ScsServiceHeader">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.ScsServiceHea der" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="callingSystem" nillable="true" type="xsd:string" />

<xsd:element name="requestID" nillable="true" type="xsd:string" />

<xsd:element name="serviceName" nillable="true" type="xsd:string" />

<xsd:element name="serviceVersion" nillable="true" type="xsd:string" />

<xsd:element name="tradingPartnerID" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:element name="scsServiceHeader" nillable="true"
type="tns:ScsServiceHeader" />

<xsd:complexType name="CallService">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallService" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="PDataXML" nillable="true" type="xsd:string" />

<xsd:element name="PInstructionsXML" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="CallServiceResponse">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallServiceRe sponse" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="callServiceResult" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

</s:schema>

<s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://systinet.com/xsd/SchemaTypes/"
xmlns:xns4="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
elementFormDefault="qualified"
targetNamespace="http://systinet.com/xsd/SchemaTypes/">

<xsd:import
namespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/" />

<xsd:element name="p0" nillable="true" type="xns4:CallService" />

<xsd:element name="CallServiceResponse_Response" nillable="true"
type="xns4:CallServiceResponse" />

</s:schema>

</wsdl:types>

<wsdl:message name="ServiceRootSoap_CallService_Response_Soap">

<wsdl:part name="response" element="s3:CallServiceResponse_Response" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_CallService__Request_Soap">

<wsdl:part name="p0" element="s3:p0" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_header_Soap">

<wsdl:part name="header_0" element="s2:scsServiceHeader" />

</wsdl:message>

<wsdl:message name="runtimeHeaders_0">

<wsdl:part name="header_0" element="s1:instance" />

<wsdl:part name="header_1" element="s0:TxId" />

</wsdl:message>

<wsdl:portType name="ServiceRootSoap">

<wsdl:operation name="CallService" parameterOrder="p0">

<wsdl:input message="tns:ServiceRootSoap_CallService__Request_ Soap" />

<wsdl:output message="tns:ServiceRootSoap_CallService_Response_ Soap" />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="ServiceRootSoap" type="tns:ServiceRootSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />

<wsdl:operation name="CallService">

<map:java-operation name="CallService"
signature="KExzdGVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ 1Y3QvQ2FsbFNlcnZpY2U7KUxzd
GVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZ pY2VSZXNwb25zZTs="
xmlns:map="http://systinet.com/mapping/" />

<soap:operation
soapAction="http://webservices.hedberg.comServiceRootSoap#CallService ?KExzdG
VlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZp Y2U7KUxzdGVlbGNhc2Uvc2Vydm
VyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2VSZXNwb25zZTs= " style="document" />

<wsdl:input>

<soap:body use="literal" parts="p0" />

<soap:header message="tns:ServiceRootSoap_header_Soap" part="header_0"
use="literal" />

</wsdl:input>

<wsdl:output>

<soap:body use="literal" parts="response" />

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="ServiceRootSoap">

<wsdl:port name="ServiceRootSoap" binding="tns:ServiceRootSoap">

<soap:address location="http://<snipped>/wasp/ServiceRoot" />

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

------------------------------- END OF WSDL
file ----------------------------------

"Dan Rogers" <da***@microsoft.com> wrote in message
news:RH**************@cpmsftngxa10.phx.gbl...
Hi Jerome,

There isn't enough of the WSDL Types section in your post to determine what the right value for the namespace should be. If the WSDL is correctly
formed, add-web-reference should do the job. You shouldn't have to be
sending XML fragments - you can work with well formed classes (if you
prefer). If you are creating the XML nodes by hand, you should use
CreateNode instead of CreateElement so you can pass in the right namespace
value. The targetNamespace from the schema in the WSDL types section
should be the value you pass.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
From: "Jerome Cohen" <yo**********@structuredweb.com>
Subject: badly formed XML when calling a web service
Date: Tue, 14 Dec 2004 21:44:16 -0500
Lines: 273
Organization: SW
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <Op**************@TK2MSFTNGP14.phx.gbl>
Newsgroups:
microsoft.public.dotnet.framework.webservices,micr osoft.public.dotnet.framew ork.webservices.enhancements,microsoft.public.webs ervices
NNTP-Posting-Host: 66.45.236.227
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP14 phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices.enha ncements:5156
microsoft.public.webservices:2599
microsoft.public.dotnet.framework.webservices:8101
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web
reference created the syntax below(reference.vb).

I changed the data type for the structure that contains the XML data from
the default "String" to "xml.xmldocument" to enable easy filling of the
data.

my client code creates an XML document class, fills the data using standard xml dom calls, and then invokes the web service.

the server refuses my call because the XML element below the root element
(customerGeneralInquiryRequests ) contains an empty "xmlns" attribute. How
do I get rid of it? I tried to define PDataXML as a node, explicitly declare the namespace as "nothing" when calling "CreateElement", nothing helps!

attached: samples from the reference file, my code that fills the XML
framgment, the WSDL retrieved from the web serrver, and from the output
trace.

any help will be appreciated!
note: a second question. the process by which the "p0" and "PDataXML"
elements are created in the request body are unclear to me. can anyone
explain or refer to good explanations? thanks!
---- FROM the client code --------------------------
Dim svc As New ServiceRootSoap

<SNIPPED CODE>

Dim aResult As CallServiceResponse

Dim aRequest As New CallService

Dim aRootNode, aDataNode As XmlNode

Dim aXMLDoc As New XmlDocument

aRootNode = aXMLDoc.CreateElement(Nothing, "customerGeneralInquiryRequests", Nothing)

aXMLDoc.AppendChild(aRootNode)

<SNIPPED CODE>
aRequest.PDataXML = aXMLDoc

Try

aResult = svc.CallService(aRequest)

---- END OF from client code ----------------------

---- FROM reference.vb -------------------------------
<System.Web.Services.Protocols.SoapHeaderAttribute ("scsServiceHeader"), _
System.Web.Services.Protocols.SoapDocumentMethodAt tribute("http://webservice s.hedberg.comServiceRootSoap#CallService?KExzdGVlb GNhc2Uvc2VydmV"& _
"yL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2U7KUxzdGVlbGNh c2Uvc2VydmVyL2lmYWNlcy9zdH J1Y3Q"& _

"vQ2FsbFNlcnZpY2VSZXNwb25zZTs=",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Bare)>
_Public Function
CallService(<System.Xml.Serialization.XmlElementAt tribute([Namespace]:="http ://systinet.com/xsd/SchemaTypes/", IsNullable:=true)> ByVal p0 As
CallService) As
<System.Xml.Serialization.XmlElementAttribute("Cal lServiceResponse_Response" , [Namespace]:="http://systinet.com/xsd/SchemaTypes/", IsNullable:=true)>
CallServiceResponse

Dim results() As Object = Me.Invoke("CallService", New Object() {p0})

Return CType(results(0),CallServiceResponse)

End Function

.........

<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://systinet.com /wsdl/steelcase/server/ifaces/struct/")> _

Public Class CallService
'<remarks/>

<System.Xml.Serialization.XmlElementAttribute(IsNu llable:=True)> _

Public PDataXML As Xml.XmlDocument 'string

.....

---- END OF from reference.vb ----------------------------------

---- FROM the output trace ---------------------------------------
<soap:Body wsu:Id="Id-61872b1c-682f-49eb-9c07-bd40aa4b42b1">
<p0 xmlns="http://systinet.com/xsd/SchemaTypes/">
<PDataXML
xmlns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">
<customerGeneralInquiryRequests xmlns="">
<customerGeneralInquiryRequest>
.......
---- END OF from the output trace ---------------------------------------


---- FROM the WSDL----------------------------------------------
...........
<xsd:complexType name="CallService">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallService" />

</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="PDataXML" nillable="true" type="xsd:string" />

<xsd:element name="PInstructionsXML" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="CallServiceResponse">

<xsd:annotation>

<xsd:appinfo>

<map:java-type name="steelcase.server.ifaces.struct.CallServiceRe sponse" />
</xsd:appinfo>

</xsd:annotation>

<xsd:sequence>

<xsd:element name="callServiceResult" nillable="true" type="xsd:string" />

</xsd:sequence>

</xsd:complexType>

</s:schema>

<s:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://systinet.com/xsd/SchemaTypes/"
xmlns:xns4="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
elementFormDefault="qualified"
targetNamespace="http://systinet.com/xsd/SchemaTypes/">

<xsd:import
namespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/" />

<xsd:element name="p0" nillable="true" type="xns4:CallService" />

<xsd:element name="CallServiceResponse_Response" nillable="true"
type="xns4:CallServiceResponse" />

</s:schema>

</wsdl:types>

<wsdl:message name="ServiceRootSoap_CallService_Response_Soap">

<wsdl:part name="response" element="s3:CallServiceResponse_Response" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_CallService__Request_Soap">

<wsdl:part name="p0" element="s3:p0" />

</wsdl:message>

<wsdl:message name="ServiceRootSoap_header_Soap">

<wsdl:part name="header_0" element="s2:scsServiceHeader" />

</wsdl:message>

<wsdl:message name="runtimeHeaders_0">

<wsdl:part name="header_0" element="s1:instance" />

<wsdl:part name="header_1" element="s0:TxId" />

</wsdl:message>

<wsdl:portType name="ServiceRootSoap">

<wsdl:operation name="CallService" parameterOrder="p0">

<wsdl:input message="tns:ServiceRootSoap_CallService__Request_ Soap" />

<wsdl:output message="tns:ServiceRootSoap_CallService_Response_ Soap" />

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="ServiceRootSoap" type="tns:ServiceRootSoap">

<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />

<wsdl:operation name="CallService">

<map:java-operation name="CallService"
signature="KExzdGVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ 1Y3QvQ2FsbFNlcnZpY2U7KUxzd GVlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZ pY2VSZXNwb25zZTs="
xmlns:map="http://systinet.com/mapping/" />

<soap:operation
soapAction="http://webservices.hedberg.comServiceRootSoap#CallService ?KExzdG VlbGNhc2Uvc2VydmVyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZp Y2U7KUxzdGVlbGNhc2Uvc2Vydm VyL2lmYWNlcy9zdHJ1Y3QvQ2FsbFNlcnZpY2VSZXNwb25zZTs= " style="document" />

<wsdl:input>

<soap:body use="literal" parts="p0" />

<soap:header message="tns:ServiceRootSoap_header_Soap" part="header_0"
use="literal" />

</wsdl:input>

<wsdl:output>

<soap:body use="literal" parts="response" />

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="ServiceRootSoap">

<wsdl:port name="ServiceRootSoap" binding="tns:ServiceRootSoap">

<soap:address location="http://<deleted>/ServiceRoot" />

</wsdl:port>

</wsdl:service>

</wsdl:definitions>

---------- END OF from the WSDL -----------------------------------------

Nov 23 '05 #3

P: n/a
Hi Jerome,

The relevant schema is this one:
<s:schema
xmlns:tns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/"
xmlns:map="http://systinet.com/mapping/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
targetNamespace="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">

<xsd:complexType name="ScsServiceHeader">
<xsd:sequence>
<xsd:element name="callingSystem" nillable="true" type="xsd:string" />
<xsd:element name="requestID" nillable="true" type="xsd:string" />
<xsd:element name="serviceName" nillable="true" type="xsd:string" />
<xsd:element name="serviceVersion" nillable="true" type="xsd:string" />
<xsd:element name="tradingPartnerID" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

<xsd:element name="scsServiceHeader" nillable="true"
type="tns:ScsServiceHeader" />

<xsd:complexType name="CallService">
<xsd:sequence>
<xsd:element name="PDataXML" nillable="true" type="xsd:string" />
<xsd:element name="PInstructionsXML" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="CallServiceResponse">
<xsd:sequence>
<xsd:element name="callServiceResult" nillable="true" type="xsd:string"
/>
</xsd:sequence>
</xsd:complexType>
</s:schema>

I've removed some of the annotations to make it clearer. Now, here is what
you say the XML that you are manually creating looks like:

<PDataXML xmlns="http://systinet.com/wsdl/steelcase/server/ifaces/struct/">
<customerGeneralInquiryRequests xmlns="">

It really is hard to work from this snippet, since PDataXml should NOT have
children, at least not according to this schema.

So I do think that a) The XML you are sending is not interface compliant.
I'd need to see the SOAP payload you are sending to make sure, but on first
glance, I'd expect to see that customerGeneralInquiryRequest to have some
namespace. As you've created it, it appears to be an un-namespaced child of
PDataXml - but we've already established that the PDataXml element should
not have any child elements.

So the question comes down to: How are you creating this XML, and why have
you chosen to make PDataXml have child elements in the non-namespace?
Since I'm positive you intend to make the XML represent the format expected
by the service, I'd have to say without looking that whatever code you've
created to generate this XML stream is just plain not up to spec.

Why did you decide to change the generated proxy code that add-web
reference created? It likely was workable as generated, and kept you from
having to play with XML.

Regards

Dan
Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.